package com.dz.tool.Service.Impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.dz.tool.Entity.WebMigrateOtoLog;
import com.dz.tool.Utils.Excel.ExcelUtil;
import com.dz.tool.Utils.Txt.TXTUtils;
import com.dz.tool.Dao.Master.MasterOracleMapper;
import com.dz.tool.Dao.Slave.SlaveMysqlMapper;
import com.dz.tool.Dao.Slave.SlaveOracleMapper;
import com.dz.tool.Service.OracleServer;
import com.dz.tool.Utils.CMDUtils;
import com.dz.tool.Utils.ConnectionUtils;
import com.dz.tool.Vo.OracleField;
import com.dz.tool.Vo.OracleTable;
import org.apache.http.HttpHost;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.CountDownLatch;

@Service
public class OracleServerImpl implements OracleServer {

    final
    MasterOracleMapper masterOracleMapper;
    final
    SlaveMysqlMapper slaveMysqlMapper;
    final
    SlaveOracleMapper slaveOracleMapper;

    public OracleServerImpl(MasterOracleMapper oracleMapper, SlaveMysqlMapper mysqlMapper, SlaveOracleMapper slaveOracleMapper) {
        this.masterOracleMapper = oracleMapper;
        this.slaveMysqlMapper = mysqlMapper;
        this.slaveOracleMapper = slaveOracleMapper;
    }

    @Value("${spring.datasource.dynamic.datasource.db1.url}")
    private String MasterUrl;
    @Value("${spring.datasource.dynamic.datasource.db1.username}")
    private String MasterUsername;
    @Value("${spring.datasource.dynamic.datasource.db1.password}")
    private String MasterPassword;
    @Value("${spring.datasource.master.databaseName}")
    private String MasterDatabaseName;


    @Value("${spring.datasource.dynamic.datasource.db2.url}")
    private String SlaveUrl;
    @Value("${spring.datasource.dynamic.datasource.db2.username}")
    private String SlaveUsername;
    @Value("${spring.datasource.dynamic.datasource.db2.password}")
    private String SlavePassword;
    @Value("${spring.datasource.slave.databaseName}")
    private String SlaveDatabaseName;

    ///////////////////////////////////////////////////////////////////////////
    // todo Oracle 转 Oracle (通过数据泵整个库进行迁移)
    // todo 问题：
    //      (1) 备份为远程备份，备份后的文件存放在远程计算机上，这个程序拿不到远程文件，除非这个程序与被备份数据库在同一台机子上 需要定义dblink
    //      (2) 数据泵再导入的时候会出现 触发器 关联的库表不正确的现象，但是 是 10条中存在1，2条，估计得手动查看
    // todo 参数 dataList 是否导出数据 true为导出 与之相反 只导出表结构
    ///////////////////////////////////////////////////////////////////////////
    @Override
    public void OracleToOracle(boolean dataList){

        System.out.println("开始获取主库数据");

        List<String> exMessage = new ArrayList<>();

        if (StringUtils.isBlank(MasterUrl)) {
            System.out.println("spring.datasource.master.url 信息不全");
            return;
        }

        String endUrl = MasterUrl.substring(MasterUrl.indexOf("@"),MasterUrl.length());

        String endUrl2 = endUrl.substring(0,endUrl.lastIndexOf(":"));

        endUrl = endUrl2 + "/" +  endUrl.substring(endUrl.lastIndexOf(":")+1,endUrl.length());

        String slaUrl = SlaveUrl.substring(SlaveUrl.indexOf("@"),SlaveUrl.length());

        String slaUrl2 = slaUrl.substring(0,slaUrl.lastIndexOf(":"));

        slaUrl = slaUrl2 + "/" +  slaUrl.substring(slaUrl.lastIndexOf(":")+1,slaUrl.length());

        String fileName = SlaveUsername + System.currentTimeMillis() + ".DMP";

        String logName = fileName.replaceAll(".dmp",".log");

        List<String> zeroTable = masterOracleMapper.selectCountZeroTable();

        if (zeroTable.size()>0) {
            System.out.println("发现有空数据数据表，开始处理不能够导出问题");
            for (String sql : zeroTable) {
                try {
                    masterOracleMapper.creatOracle(sql);
                }catch (Exception e){
                    exMessage.add(sql);
                }
            }
            System.out.println("处理完成！！");
        }

        if (exMessage.size()>0) {
            for (String ex : exMessage) {
                System.out.println(ex);
            }
            System.out.println("以上是空数据表初始化失败的表，这些表有可能迁移失败！！");
        }

        String cmdBac = "EXPDP " +
                MasterUsername +
                "/" +
                MasterPassword + endUrl +
                " directory=DATA_PUMP_DIR" +
                " DUMPFILE="  + fileName ;//+ " LOGFILE="  +logName;

        if (!dataList) {
            cmdBac = cmdBac + " rows=n";
        }

        System.out.println(cmdBac);

        try {
            CMDUtils.runCmd(cmdBac);
        } catch (Exception e) {
            System.out.println("导出命令报错！！暂时无法打印cmd日志，请通过打印语句测试");
            return;
        }

        System.out.println("数据库文件获取成功！！");

        String cmdINP = "IMPDP " +
                SlaveUsername +
                "/" +
                SlavePassword +
                slaUrl +
                " DUMPFILE=" + fileName;


        String schema = " remap_schema=" + MasterUsername + ":" + SlaveUsername;

        String MasterTableSpace = masterOracleMapper.selectTableSpace(MasterUsername);

        String SlaveTableSpace = slaveOracleMapper.selectTableSpace(SlaveUsername);

        String tablespace = " remap_tablespace=" + MasterTableSpace + ":" + SlaveTableSpace;


        cmdINP = cmdINP + schema + tablespace;

        System.out.println(cmdINP);

        try {
            CMDUtils.runCmd(cmdINP);
        } catch (Exception e) {
            System.out.println("导入命令报错！！暂时无法打印cmd日志，请通过打印语句测试");
            return;
        }

        System.out.println("导入完成！！！开始处理触发器隐患问题");

        List<Map<String, Object>> masterTriggers = masterOracleMapper.selectTriggersList(MasterUsername);
        System.out.println("主库触发器数量为：" + masterTriggers.size());

        List<Map<String, Object>> slaveTriggers = masterOracleMapper.selectTriggersList(SlaveUsername);
        System.out.println("从库触发器数量为：" + slaveTriggers.size());

        // todo 先注释没想好 问题在于 触发器的创建语句的条件都需要掌控
//        if (slaveTriggers.size()>0) {
//            System.out.println("开始处理从库触发器");
//            for (Map<String, Object> slaveTrigger : slaveTriggers) {
//                String sql = "DROP TRIGGER " + slaveTrigger.get("TRIGGER_NAME");
//                try {
//                    slaveOracleMapper.creatOracle(sql);
//                }catch (Exception e){
//                    System.out.println("删除触发器失败：" + slaveTrigger.get("TRIGGER_NAME"));
//                }
//            }
//            System.out.println("从库触发器处理完成");
//        }
//
//        if (masterTriggers.size()>0) {
//            System.out.println("开始迁移主库触发器");
//
//            for (Map<String, Object> masterTrigger : masterTriggers) {
//                String sql = "CREATE OR REPLACE TRIGGER \""+SlaveUsername+"\".\""+masterTrigger.get("TRIGGER_NAME")+"\" BEFORE INSERT REFERENCING OLD AS \"OLD\" NEW AS \"NEW\" FOR EACH ROW " + masterTrigger.get("TRIGGER_BODY");
//
//            }
//
//            System.out.println("主库触发器迁移完成");
//        }

        System.out.println("迁移成功！！！请检查触发器是否存在隐患");


        // 查询文件目录列表
        // select * from dba_directories

        // 新版 导入 导出 命令
        // rows=n 不要数据
        // EXPDP C##TEST1/root@127.0.0.1:1521/ORCL DUMPFILE=AAAA.dmp
        // EXPDP C##TEST1/root@127.0.0.1:1521/ORCL SCHEMAS=C##SCROTTS DUMPFILE=SCROTT1660548062236.dmp LOGFILE=SCROTT1660548062236.log
        // IMPDP C##SCROTTS/root@127.0.0.1:1521/ORCL DUMPFILE=AAAA.dmp remap_schema=C##TEST1:C##SCROTTS remap_tablespace=C##TEST1:C##SCROTTS
        // impdp C##SCROTTS/root@127.0.0.1:1521/ORCL remap_schema=TEST1:C##SCROTTS remap_tablespace=TEST1:C##SCROTTS DIRECTORY=DATA_PUMP_DIR DUMPFILE=SCROTT1660548062236.dmp

        // 旧版  tablespaces=TS2
        // exp C##SCROTTS/root@127.0.0.1:1521/ORCL file=D:\A\database-tools\file\SCROTT1660570002229.dmp log=D:\A\database-tools\file\SCROTT1660570002229.log
        // imp SCROTT/scrott@192.168.1.9:1521/ORCL tablespaces=SCROTT  file=D:\A\database-tools\file\SCROTT1660571367246.dmp full=y ignore=y

//        CREATE OR REPLACE TRIGGER "C##TEST1"."WEB_CLM_MAIN_TRIGGER" BEFORE INSERT REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
//                begin
//        select WEB_CLM_MAIN_N_MAIN_ID.nextval into:New.N_MAIN_ID from dual;
//        end;

    }


    ///////////////////////////////////////////////////////////////////////////
    // todo Oracle备份
    // todo 注意：使用master链接库
    ///////////////////////////////////////////////////////////////////////////
    @Override
    public void OracleBackUp() throws Exception{

        System.out.println("开始备份数据库");

        List<String> exMessage = new ArrayList<>();

        if (StringUtils.isBlank(MasterUrl)) {
            System.out.println("spring.datasource.master.url 信息不全");
            return;
        }

        String endUrl = MasterUrl.substring(MasterUrl.indexOf("@"),MasterUrl.length());

        String endUrl2 = endUrl.substring(0,endUrl.lastIndexOf(":"));

        endUrl = endUrl2 + "/" +  endUrl.substring(endUrl.lastIndexOf(":")+1,endUrl.length());

        String slaUrl = SlaveUrl.substring(SlaveUrl.indexOf("@"),SlaveUrl.length());

        String slaUrl2 = slaUrl.substring(0,slaUrl.lastIndexOf(":"));

        slaUrl = slaUrl2 + "/" +  slaUrl.substring(slaUrl.lastIndexOf(":")+1,slaUrl.length());

        String fileName = SlaveUsername + System.currentTimeMillis() + ".DMP";

        String logName = fileName.replaceAll(".dmp",".log");

        List<String> zeroTable = masterOracleMapper.selectCountZeroTable();

        if (zeroTable.size()>0) {
            System.out.println("发现有空数据数据表，开始处理不能够导出问题");
            for (String sql : zeroTable) {
                try {
                    masterOracleMapper.creatOracle(sql);
                }catch (Exception e){
                    exMessage.add(sql);
                }
            }
            System.out.println("处理完成！！");
        }

        if (exMessage.size()>0) {
            for (String ex : exMessage) {
                System.out.println(ex);
            }
            System.out.println("以上是空数据表初始化失败的表，这些表有可能迁移失败！！");
        }

        String cmdBac = "EXPDP " +
                MasterUsername +
                "/" +
                MasterPassword + endUrl +
                " directory=DATA_PUMP_DIR" +
                " DUMPFILE="  + fileName;//+ " LOGFILE="  +logName;

        System.out.println(cmdBac);

        try {
            CMDUtils.runCmd(cmdBac);
        } catch (Exception e) {
            System.out.println("导出命令报错！！暂时无法打印cmd日志，请通过打印语句测试");
            return;
        }

        System.out.println("数据库备份成功！！");
    }

    ///////////////////////////////////////////////////////////////////////////
    // mysql 针对数据库 生成字段Excel文档
    ///////////////////////////////////////////////////////////////////////////
    @Override
    public void OracleToExcel(HttpServletResponse response) {
        List<String> tableNames = new ArrayList<>();
        // 根据指定数据表获取结构
        // 根据结构拆除 表名 列名 数据类型 长度 注释
        // 导出Excel

        List<Map<String,Object>> endList = new ArrayList<>();
        // 初始表头
        Map<String,Object> startMap = new HashMap<>();
        startMap.put("tableName","表列表");
        // 表头数据
        List<Object> headOne = Arrays.asList("表名","表注释");
        // 将数据汇总
        List<List<Object>> startSheetDataList = new ArrayList<>();
        startSheetDataList.add(headOne);

        // 数据
        Map<String, String> zhushi = new HashMap<>();
        List<Map<String, String>> maps = masterOracleMapper.selectTableComment();
        if (maps.size()>0) {
            for (Map<String, String> map : maps) {
                zhushi.put(map.get("TABLE_NAME"),map.get("TABLE_COMMENT"));
                tableNames.add(map.get("TABLE_NAME"));
            }
        }
        for (String name : tableNames) {
            List<Object> mysqlFieldsList = new ArrayList<>();
            mysqlFieldsList.add(name);
            mysqlFieldsList.add(zhushi.get(name));
            startSheetDataList.add(mysqlFieldsList);
        }

        startMap.put("sheetDataList",startSheetDataList);
        endList.add(startMap);
        int i = 1;
        for (String tableName : tableNames) {
            System.out.println(tableNames.size()+"/"+i+++"："+tableName);
            Map<String,Object> map = new HashMap<>();
            map.put("tableName",tableName);
            QueryWrapper<Object> queryWrapper = new QueryWrapper<>();
            queryWrapper
                    .eq("atc.TABLE_NAME",tableName).eq("atc.OWNER",MasterDatabaseName).orderByAsc("COLUMN_ID");
            List<OracleField> mysqlFields = masterOracleMapper.selectTableNameOnCNAndTP(queryWrapper);
            System.out.println(mysqlFields.size());
            // 表头数据
            List<Object> head = Arrays.asList("表名","列名","数据类型","长度","注释");
            // 将数据汇总
            List<List<Object>> sheetDataList = new ArrayList<>();
            sheetDataList.add(head);
            // 数据
            if (mysqlFields.size()>0) {
                for (OracleField mysqlField : mysqlFields) {
                    List<Object> mysqlFieldsList = new ArrayList<>();
                    mysqlFieldsList.add(tableName);
                    mysqlFieldsList.add(mysqlField.getCOLUMN_NAME());
                    mysqlFieldsList.add(mysqlField.getDATA_TYPE());
                    mysqlFieldsList.add(mysqlField.getDATA_LENGTH());
                    mysqlFieldsList.add(mysqlField.getZHU_SHI());
                    sheetDataList.add(mysqlFieldsList);
                }
            }
            map.put("sheetDataList",sheetDataList);
            endList.add(map);
        }

        // 导出数据
        ExcelUtil.exportAll(response,null,"dataBaseToolExcel", endList);

    }

    ///////////////////////////////////////////////////////////////////////////
    // todo Oracle 转 Mysql
    // todo 参数 tableList 迁移的表名列表，不写就默认迁移全部
    //      参数 dataBool 是否迁移数据 true为迁移 与之相反 只迁移表结构
    //      参数 dataBaseName 如果数据表不在用户名之下，写所属的数据库，前提是打开dblink,或者有足够的权限访问
    //      参数 dataBaseCreat 默认目标数据库没有对应的表，则创建，但是如果存在相同表名，那 删除重新创建 true，还是直接补充数据 false
    //      参数 tableMapping 表名映射，如果源表名和目标表名不一样，可以在这里配置
    ///////////////////////////////////////////////////////////////////////////
    @Override
    public void OracleToMysql(String dataBaseName,List<String> tableList,boolean dataBool,boolean dataBaseCreat, Map<String,String> tableMapping) throws Exception {
        SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        MasterUsername = MasterUsername.toUpperCase();
        List<String> list = new ArrayList<>();

        if (tableList!=null && tableList.size()>0) {
            for(String sn : tableList){
                list.add(sn);
            }
        }
        else if (StringUtils.isNotBlank(dataBaseName)) {
            list = masterOracleMapper.selectTableNameAllToDataBase(dataBaseName);
        }
        else {
            list = selectAllTableName();
        }

        List<OracleTable> extable = new ArrayList<>();

        // 获取所有序列
        List<Map<String, Object>> mapsSequence = new ArrayList<>();
        try {
            mapsSequence = masterOracleMapper.selectSequence(MasterUsername);
            System.out.println("序列数量为：" + mapsSequence.size());
        }catch (Exception e){
            System.out.println("获取序列失败！！疑似没有权限");
        }


        int count = list.size();
        int number = 1;

        for (String tableName : list) {

            System.out.println("=============================");
            System.out.println("开始时间："+ sdf.format(new Date()));
            System.out.println(number++ + "/" + count + " 数据表名：" + tableName + " 开始");

            OracleTable oracleTable = selectOracle(dataBaseName,tableName);

            String mappingTableName = tableName;
            if (tableMapping!=null) {
                String string = tableMapping.get(mappingTableName);
                if (StringUtils.isNotBlank(string)) {
                    oracleTable.setTableNameSlave(string);
                }
            }

            if (oracleTable.getFieldList().size()<1) {
                oracleTable.setExMessage("此数据表无字段或者当前用户下没有这个表，无法迁移！！");
                extable.add(oracleTable);
                continue;
            }

            //判断主键
            List<String> zhujianlist = masterOracleMapper.selectTableId(oracleTable.getTableName());
            if (zhujianlist.size()>0) {
                for (String s : zhujianlist) {
                    for (OracleField oracleField : oracleTable.getFieldList()) {
                        if (s.equals(oracleField.getCOLUMN_NAME())) {
                            oracleField.setZHU_JIAN(1);
                            break;
                        }
                    }
                }
            }

            //对比注释
            List<OracleField> oracleFields = masterOracleMapper.selectCommot(oracleTable.getTableName());
            if (oracleFields!=null) {
                if (oracleFields.size()>0) {
                    for (OracleField oracleField : oracleTable.getFieldList()) {
                        for (OracleField field : oracleFields) {
                            if (oracleField.getCOLUMN_NAME().equals(field.getCOLUMN_NAME())) {
                                oracleField.setZHU_SHI(field.getZHU_SHI());
                                break;
                            }
                        }
                    }
                }
            }


            // 创建表会删除同名旧表
            if (dataBaseCreat) {
                try {
                    System.out.println("drop table "+ oracleTable.getTableNameSlave());
                    slaveMysqlMapper.creatMysql("drop table " + oracleTable.getTableNameSlave());
                }catch (Exception r){

                }
            }


            // 创建SQL
            creatTableSqlMysql(oracleTable);

            if (StringUtils.isNotBlank(oracleTable.getExMessage())) {
                System.out.println(oracleTable.getExMessage());
                extable.add(oracleTable);
                continue;
            }


            boolean InTable = false;
            String selectTable = slaveMysqlMapper.selectTable(oracleTable.getTableNameSlave());
            if (StringUtils.isNotBlank(selectTable)) {
                InTable = true;
                System.out.println("数据表存在，跳过创建！！");
            }
            else {
                InTable = false;
                System.out.println("数据表不存在，按照原始库开始创建表！！");
            }

            if (!InTable) {
                // 执行创建表
                try {
                    slaveMysqlMapper.creatMysql(oracleTable.getTableSql());
                }catch (Exception e){
                    oracleTable.setExMessage("创建失败 ：" + oracleTable.getTableSql());
                    System.out.println(oracleTable.getExMessage());
                    extable.add(oracleTable);
                    continue;
                }


                // 创建主键字段
                System.out.println("主键字段数量为：" + oracleTable.getFieldKeyList().size());
                if (oracleTable.getFieldKeyList().size()>0) {
                    String FieldKeySql = "alter table " + oracleTable.getTableNameSlave() + " add primary key(";
                    int fieldKeyn = 0;
                    for (String fieldKey : oracleTable.getFieldKeyList()) {
                        if (fieldKeyn!=0) {
                            FieldKeySql = FieldKeySql + ",";
                        }
                        FieldKeySql = FieldKeySql + fieldKey;
                        ++fieldKeyn;
                    }
                    FieldKeySql = FieldKeySql + ")";
                    System.out.println(FieldKeySql);
                    try {
                        slaveMysqlMapper.creatMysql(FieldKeySql);
                    }catch (Exception e){
                        oracleTable.setExMessage("创建主键失败 ：" + FieldKeySql);
                        extable.add(oracleTable);
                        continue;
                    }
                }
                System.out.println("主键创建完成");


                // 创建索引、对比索引
                List<String> selectFiledIndex = masterOracleMapper.selectFiledIndex(oracleTable.getTableName());
                System.out.println("索引字段数量为：" + selectFiledIndex.size());
                if (selectFiledIndex!=null) {
                    if (selectFiledIndex.size()>0) {
                        String exMessage = "";
                        for (String filedIndex : selectFiledIndex) {
                            try {
                                String creatIndexSql = "ALTER TABLE `"+oracleTable.getTableNameSlave()+"` ADD INDEX(`"+filedIndex+"`)";
                                System.out.println(creatIndexSql);
                                slaveMysqlMapper.creatMysql(creatIndexSql);
                            }catch (Exception e){
                                if (StringUtils.isNotBlank(exMessage)) {
                                    exMessage = exMessage + ",";
                                }
                                exMessage = exMessage + "数据表：" + oracleTable.getTableNameSlave() + ", 索引字段：" + filedIndex + "创建失败！！";
                            }
                        }
                        if (StringUtils.isNotBlank(exMessage)) {
                            oracleTable.setExMessage(exMessage);
                            extable.add(oracleTable);
                        }
                    }
                }
                System.out.println("索引创建完成");


                // 获取所有触发器
                List<Map<String, Object>> mapsTriggers = masterOracleMapper.selectTriggers(MasterUsername,oracleTable.getTableName());
                System.out.println("触发器数量为：" + mapsTriggers.size());
                if (mapsTriggers.size()>0) {

                    System.out.println("开始处理触发器");
                    String exMessage = "";

                    List<String> trigger_bodyList = new ArrayList<>();
                    for (Map<String, Object> mapsTrigger : mapsTriggers) {

                        String trigger_body = ((String) mapsTrigger.get("TRIGGER_BODY")).toLowerCase();
                        boolean keyTrigger = false;

                        if (mapsSequence.size()>0) {
                            for (Map<String, Object> stringObjectMap : mapsSequence) {

                                String sequence_name = " " + ((String)stringObjectMap.get("SEQUENCE_NAME")).toLowerCase();
                                String sequence_name2 = sequence_name + ".nextval";
                                String sequence_name3 = sequence_name2 + " into:new.";

                                if (trigger_body.contains(sequence_name) && trigger_body.contains(sequence_name2) && trigger_body.contains(sequence_name3)) {
                                    keyTrigger = true;
                                    trigger_body = trigger_body.substring(trigger_body.indexOf(sequence_name3) + sequence_name3.length(),trigger_body.length());
                                    String keyField = trigger_body.substring(0,trigger_body.indexOf(" "));
                                    System.out.println("主键自增：" + keyField);
                                    String fieldType = "";
                                    for (OracleField oracleField : oracleTable.getFieldList()) {
                                        if (oracleField.getCOLUMN_NAME().toLowerCase().equals(keyField)) {
                                            fieldType = oracleField.getMYSQL_FIELD_TYPE();
                                            keyField = oracleField.getCOLUMN_NAME();
                                            break;
                                        }
                                    }
                                    String keyFieldSql = "alter table " + oracleTable.getTableNameSlave() + " modify " + keyField + " " + fieldType + " auto_increment";
                                    System.out.println(keyFieldSql);
                                    try {
                                        slaveMysqlMapper.creatMysql(keyFieldSql);
                                    }catch (Exception e){
                                        if (StringUtils.isNotBlank(exMessage)) {
                                            exMessage = exMessage + ",";
                                        }
                                        exMessage = exMessage + "数据表：" + oracleTable.getTableNameSlave() + ", 自增字段：" + keyField + "创建失败！！" + keyFieldSql;
                                    }
                                }
                            }
                        }

                        if (!keyTrigger) {
                            trigger_bodyList.add(creatTrigger(mapsTrigger));
                        }

                    }

                    System.out.println("非主键自增触发器存在：" + trigger_bodyList.size());

                    if (trigger_bodyList.size()>0) {
                        for (String trigger_body : trigger_bodyList) {
                            try {
                                slaveMysqlMapper.creatMysql(trigger_body);
                            }catch (Exception e){
                                if (StringUtils.isNotBlank(exMessage)) {
                                    exMessage = exMessage + ",";
                                }
                                exMessage = exMessage + "数据表：" + oracleTable.getTableName() + ", 创建触发器失败！！语句应该是不合归： " + trigger_body;
                            }

                        }
                    }

                    if (StringUtils.isNotBlank(exMessage)) {
                        oracleTable.setExMessage(exMessage);
                        extable.add(oracleTable);
                        continue;
                    }

                    System.out.println("处理触发器结束");
                }
            }

            if (dataBool) {

                int insertNum = 50000; // 开始获取相关表的数据
                int threadCount = 5; // 线程数量

                List<Map<String, Object>> dataList = null;
                String tableNameEnd = tableName;
                if (StringUtils.isNotBlank(dataBaseName)) {
                    tableNameEnd = dataBaseName + "." + tableNameEnd;
                }
                Integer selectDataCount = masterOracleMapper.selectDataCount(tableNameEnd);
                System.out.println("数据量为：" + selectDataCount);

                if (selectDataCount<=insertNum) {
                    System.out.println("一次性存储");
                    dataList = masterOracleMapper.selectData(tableNameEnd);
                    boolean bigData = inseBigData(dataList, oracleTable, extable);
                    if (!bigData) {
                        continue;
                    }
                }
                else {
                    System.out.println("批量存储");
                    final String tableNameEndFinal = tableNameEnd;

                    BigDecimal one = new BigDecimal(selectDataCount);
                    BigDecimal two = new BigDecimal(insertNum);
                    BigDecimal divide = one.divide(two, RoundingMode.HALF_UP);
                    divide = divide.add(new BigDecimal(1));
                    System.out.println("单次数量为(可能出现次数比你们算的多1,2次，不会少，原因计算逻辑有问题，懒得改，凑乎用吧，否则自己搞去)：" + divide);
                    divide = divide.divide(new BigDecimal(threadCount), RoundingMode.HALF_UP);
                    divide = divide.add(new BigDecimal(1));
                    System.out.println("除以线程次数一共为(可能出现次数比你们算的多1,2次，不会少，原因计算逻辑有问题，懒得改，凑乎用吧，否则自己搞去)：" + divide);

                    final boolean[] OK = {true,true,true,true,true};
                    final int[] start = {0};
                    final int[] end = {start[0] + insertNum};
                    for (Integer i = 1; i <= Integer.valueOf(String.valueOf(divide.toString())); i++) {

                        CountDownLatch latch = new CountDownLatch(threadCount);

                        List<Map<String, Object>> dataListFinalAll = new ArrayList<>();
                        List<Map<String, Object>> dataListFinalAll2 = new ArrayList<>();
                        List<Map<String, Object>> dataListFinalAll3 = new ArrayList<>();
                        Thread thread = new Thread(()->{
                            String sql = "SELECT * FROM (SELECT a.*,ROWNUM RN FROM " + tableNameEndFinal + " a  WHERE ROWNUM <= "+end[0]+" ) WHERE RN >= "+start[0];
                            System.out.println("开始："+ start[0] + " 结束：" + end[0]);
                            List<Map<String, Object>> dataListFinal = masterOracleMapper.creatOracleMap(sql);
                            dataListFinalAll.addAll(dataListFinal);
                            latch.countDown();
                        });
                        thread.start();
                        Thread.sleep(2000);
                        start[0] = end[0] + 1;
                        end[0] = end[0] + insertNum;

                        Thread thread2 = new Thread(()->{
                            String sql = "SELECT * FROM (SELECT a.*,ROWNUM RN FROM " + tableNameEndFinal + " a  WHERE ROWNUM <= "+end[0]+" ) WHERE RN >= "+start[0];
                            System.out.println("开始："+ start[0] + " 结束：" + end[0]);
                            List<Map<String, Object>> dataListFinal = masterOracleMapper.creatOracleMap(sql);
                            dataListFinalAll.addAll(dataListFinal);
                            latch.countDown();
                        });
                        thread2.start();
                        Thread.sleep(2000);
                        start[0] = end[0] + 1;
                        end[0] = end[0] + insertNum;

                        Thread thread3 = new Thread(()->{
                            String sql = "SELECT * FROM (SELECT a.*,ROWNUM RN FROM " + tableNameEndFinal + " a  WHERE ROWNUM <= "+end[0]+" ) WHERE RN >= "+start[0];
                            System.out.println("开始："+ start[0] + " 结束：" + end[0]);
                            List<Map<String, Object>> dataListFinal = masterOracleMapper.creatOracleMap(sql);
                            dataListFinalAll2.addAll(dataListFinal);
                            latch.countDown();
                        });
                        thread3.start();
                        Thread.sleep(2000);
                        start[0] = end[0] + 1;
                        end[0] = end[0] + insertNum;

                        Thread thread4 = new Thread(()->{
                            String sql = "SELECT * FROM (SELECT a.*,ROWNUM RN FROM " + tableNameEndFinal + " a  WHERE ROWNUM <= "+end[0]+" ) WHERE RN >= "+start[0];
                            System.out.println("开始："+ start[0] + " 结束：" + end[0]);
                            List<Map<String, Object>> dataListFinal = masterOracleMapper.creatOracleMap(sql);
                            dataListFinalAll2.addAll(dataListFinal);
                            latch.countDown();
                        });
                        thread4.start();
                        Thread.sleep(2000);
                        start[0] = end[0] + 1;
                        end[0] = end[0] + insertNum;

                        Thread thread5 = new Thread(()->{
                            String sql = "SELECT * FROM (SELECT a.*,ROWNUM RN FROM " + tableNameEndFinal + " a  WHERE ROWNUM <= "+end[0]+" ) WHERE RN >= "+start[0];
                            System.out.println("开始："+ start[0] + " 结束：" + end[0]);
                            List<Map<String, Object>> dataListFinal = masterOracleMapper.creatOracleMap(sql);
                            dataListFinalAll3.addAll(dataListFinal);
                            latch.countDown();
                        });
                        thread5.start();
                        Thread.sleep(2000);
                        start[0] = end[0] + 1;
                        end[0] = end[0] + insertNum;

                        try {
                            // 等待所有线程执行完毕
                            latch.await();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        System.out.println("等待结束");

                        if (dataListFinalAll.size()>0) {
                            System.out.println("集合存储1");
                            OK[0] = inseBigData(dataListFinalAll, oracleTable, extable);
                            if(!OK[0]||!OK[1]||!OK[2]||!OK[3]||!OK[4]){
                                System.out.println("集合存储1失败");
                                break;
                            }
                        }
                        if (dataListFinalAll2.size()>0) {
                            System.out.println("集合存储2");
                            OK[1] = inseBigData(dataListFinalAll2, oracleTable, extable);
                            if(!OK[0]||!OK[1]||!OK[2]||!OK[3]||!OK[4]){
                                System.out.println("集合存储2失败");
                                break;
                            }
                        }
                        if (dataListFinalAll3.size()>0) {
                            System.out.println("集合存储3");
                            OK[2] = inseBigData(dataListFinalAll3, oracleTable, extable);
                            if(!OK[0]||!OK[1]||!OK[2]||!OK[3]||!OK[4]){
                                System.out.println("集合存储3失败");
                                break;
                            }
                        }

                    }
                    if(!OK[0]||!OK[1]||!OK[2]||!OK[3]||!OK[4]){
                        continue;
                    }
                }

                System.out.println("存储完成");

            }

            System.out.println("数据表名：" + tableName + " 结束,目标数据表名："+oracleTable.getTableNameSlave());
            System.out.println("结束时间："+ sdf.format(new Date()));
            System.out.println("=============================");

        }

        System.out.println("迁移完成，失败数为：" + extable.size());

        if (extable.size()>0) {
            System.out.println("以下失败表名");
            StringBuffer stringBuffer = new StringBuffer();
            for (OracleTable s : extable) {
                System.out.println(s.getTableName() + "原因是：" + s.getExMessage());
                stringBuffer.append(s.getTableName() + "原因是：" + s.getExMessage());
            }
            TXTUtils.creatTxt("exception",stringBuffer.toString());
        }

    }

    ///////////////////////////////////////////////////////////////////////////
    // Oracle 转 Mysql [依靠时间来增量取数据插入处理]
    ///////////////////////////////////////////////////////////////////////////
    public void OracleToMysqlToDate(List<Map<String,String>> OracleTableList) throws Exception{

        if (OracleTableList.size()<1) {
            OracleTableList = new ArrayList<>();
        }

        if (OracleTableList.size()>0) {
            List<OracleTable> extable = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;
            slaveMysqlMapper.selectDateDAYSET();
            List<String> dateAll = slaveMysqlMapper.selectDateDAY();

            for (Map<String,String> tableOneMap : OracleTableList) {

                String tableName = tableOneMap.get("table");
                String id = tableOneMap.get("id");
                String inc_field = tableOneMap.get("inc_field");

                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + tableName + " 开始");
                OracleTable oracleTable = selectOracle(MasterDatabaseName,tableName);

                if (oracleTable.getFieldList().size()<1) {
                    oracleTable.setExMessage("此数据表无字段，无法迁移！！");
                    extable.add(oracleTable);
                    continue;
                }

                // 处理主键问题
                String[] idSpl = id.split(",");
                for (String string : idSpl) {
                    oracleTable.getFieldKeyList().add(string);
                }

                //处理字段类型
                for (OracleField oracleField : oracleTable.getFieldList()) {
                    // 类型问题
                    String FieldType = FieldType(oracleField);
                    oracleField.setMYSQL_FIELD_TYPE(FieldType);
                }

                String masterTableName = MasterDatabaseName + "." + oracleTable.getTableNameSlave();
                int threadCount = 5; // 线程数量
                final int[] i = {0};

                for (int i1 = 0; i1 < dateAll.size(); i1++) {
                    final boolean[] OK = {true,true,true,true,true};
                    CountDownLatch latch = new CountDownLatch(threadCount);

                    List<Map<String, Object>> dataListFinalAll = new ArrayList<>();
                    List<Map<String, Object>> dataListFinalAll2 = new ArrayList<>();
                    List<Map<String, Object>> dataListFinalAll3 = new ArrayList<>();

                    Thread thread = new Thread(()->{
                        String sql = "";
                        try {
                            sql = "SELECT * FROM "+masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+dateAll.get(i[0])+"', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+dateAll.get(i[0]+1)+"', 'YYYY-MM-DD')";
                        }catch (Exception e){
                            return;
                        }
                        System.out.println(sql);
                        System.out.println("开始："+ dateAll.get(i[0]) + " 结束：" + dateAll.get(i[0]+1));
                        List<Map<String, Object>> dataListFinal = masterOracleMapper.creatOracleMap(sql);
                        System.out.println("数据量："+dataListFinal.size());
                        dataListFinalAll.addAll(dataListFinal);
                        latch.countDown();
                    });
                    thread.start();
                    Thread.sleep(2000);
                    i[0] = i[0] + 1;

                    Thread thread2 = new Thread(()->{
                        String sql = "";
                        try {
                            sql = "SELECT * FROM "+masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+dateAll.get(i[0])+"', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+dateAll.get(i[0]+1)+"', 'YYYY-MM-DD')";
                        }catch (Exception e){
                            return;
                        }
                        System.out.println(sql);
                        System.out.println("开始："+ dateAll.get(i[0]) + " 结束：" + dateAll.get(i[0]+1));
                        List<Map<String, Object>> dataListFinal = masterOracleMapper.creatOracleMap(sql);
                        System.out.println("数据量："+dataListFinal.size());
                        dataListFinalAll.addAll(dataListFinal);
                        latch.countDown();
                    });
                    thread2.start();
                    Thread.sleep(2000);
                    i[0] = i[0] + 1;

                    Thread thread3 = new Thread(()->{
                        String sql = "";
                        try {
                            sql = "SELECT * FROM "+masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+dateAll.get(i[0])+"', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+dateAll.get(i[0]+1)+"', 'YYYY-MM-DD')";
                        }catch (Exception e){
                            return;
                        }
                        System.out.println(sql);
                        System.out.println("开始："+ dateAll.get(i[0]) + " 结束：" + dateAll.get(i[0]+1));
                        List<Map<String, Object>> dataListFinal = masterOracleMapper.creatOracleMap(sql);
                        System.out.println("数据量："+dataListFinal.size());
                        dataListFinalAll2.addAll(dataListFinal);
                        latch.countDown();
                    });
                    thread3.start();
                    Thread.sleep(2000);
                    i[0] = i[0] + 1;

                    Thread thread4 = new Thread(()->{
                        String sql = "";
                        try {
                            sql = "SELECT * FROM "+masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+dateAll.get(i[0])+"', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+dateAll.get(i[0]+1)+"', 'YYYY-MM-DD')";
                        }catch (Exception e){
                            return;
                        }
                        System.out.println(sql);
                        System.out.println("开始："+ dateAll.get(i[0]) + " 结束：" + dateAll.get(i[0]+1));
                        List<Map<String, Object>> dataListFinal = masterOracleMapper.creatOracleMap(sql);
                        System.out.println("数据量："+dataListFinal.size());
                        dataListFinalAll2.addAll(dataListFinal);
                        latch.countDown();
                    });
                    thread4.start();
                    Thread.sleep(2000);
                    i[0] = i[0] + 1;

                    Thread thread5 = new Thread(()->{
                        String sql = "";
                        try {
                            sql = "SELECT * FROM "+masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+dateAll.get(i[0])+"', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+dateAll.get(i[0]+1)+"', 'YYYY-MM-DD')";
                        }catch (Exception e){
                            return;
                        }
                        System.out.println(sql);
                        System.out.println("开始："+ dateAll.get(i[0]) + " 结束：" + dateAll.get(i[0]+1));
                        List<Map<String, Object>> dataListFinal = masterOracleMapper.creatOracleMap(sql);
                        System.out.println("数据量："+dataListFinal.size());
                        dataListFinalAll3.addAll(dataListFinal);
                        latch.countDown();
                    });
                    thread5.start();
                    Thread.sleep(2000);
                    i[0] = i[0] + 1;

                    try {
                        // 等待所有线程执行完毕
                        latch.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("等待结束");

                    if (dataListFinalAll.size()>0) {
                        System.out.println("集合存储1");
                        OK[0] = inseBigDataInc(dataListFinalAll, oracleTable, extable);
                        if(!OK[0]||!OK[1]||!OK[2]||!OK[3]||!OK[4]){
                            System.out.println("集合存储1失败");
                            break;
                        }
                    }
                    if (dataListFinalAll2.size()>0) {
                        System.out.println("集合存储2");
                        OK[1] = inseBigDataInc(dataListFinalAll2, oracleTable, extable);
                        if(!OK[0]||!OK[1]||!OK[2]||!OK[3]||!OK[4]){
                            System.out.println("集合存储2失败");
                            break;
                        }
                    }
                    if (dataListFinalAll3.size()>0) {
                        System.out.println("集合存储3");
                        OK[2] = inseBigDataInc(dataListFinalAll3, oracleTable, extable);
                        if(!OK[0]||!OK[1]||!OK[2]||!OK[3]||!OK[4]){
                            System.out.println("集合存储3失败");
                            break;
                        }
                    }
                }

                System.out.println("数据表名：" + tableName + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }

    }



    ///////////////////////////////////////////////////////////////////////////
    // todo Oracle 主表创建从表的DBLink
    ///////////////////////////////////////////////////////////////////////////
    @Override
    public void OracleToDblink() {
        //select * from user_sys_privs where privilege like upper('%DATABASE LINK%');

        //grant CREATE PUBLIC DATABASE LINK,DROP PUBLIC DATABASE LINK to reserve;

        //CREATE PUBLIC database link DMDWLink CONNECT TO bi_dm IDENTIFIED BY BIpwd#2021 using '(DESCRIPTION =
        //(ADDRESS = (PROTOCOL = TCP)(HOST =10.1.137.50)(PORT = 1521))
        //(CONNECT_DATA =
        //(SERVER = DEDICATED)
        //(SERVICE_NAME = rpt))
        //)';


        //drop public database link DMDWLink;

        //SELECT * FROM YU_20210105@DMDWLink;


        //SELECT S.USERNAME,
        //       DECODE(L.TYPE, 'TM', 'TABLE LOCK', 'TX', 'ROW LOCK', NULL) LOCK_LEVEL,
        //       O.OWNER,
        //       O.OBJECT_NAME,
        //       O.OBJECT_TYPE,
        //       S.SID,
        //       S.SERIAL#,
        //       S.TERMINAL,
        //       S.MACHINE,
        //       S.PROGRAM,
        //       S.OSUSER
        //  FROM V$SESSION S, V$LOCK L, DBA_OBJECTS O
        // WHERE L.SID = S.SID
        //   AND L.ID1 = O.OBJECT_ID(+)
        //   AND S.USERNAME IS NOT NULL AND USERNAME = 'RESERVE'

        //ALTER SYSTEM KILL SESSION '1753,28076';
    }


    @Override
    public void OracleToEs(String dataBaseName,List<String> OracleTableList, boolean dataBool) throws IOException {

        if (OracleTableList.size()<1) {
            OracleTableList = new ArrayList<>();
        }

        if (OracleTableList.size()>0) {

            List<OracleTable> extable = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;

            for (String tableName : OracleTableList) {

                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + tableName + " 开始");
                OracleTable oracleTable = selectOracle(dataBaseName,tableName);

                if (oracleTable.getFieldList().size()<1) {
                    oracleTable.setExMessage("此数据表无字段，无法迁移！！");
                    extable.add(oracleTable);
                    continue;
                }

                if (dataBool) {

                    // 清除旧数据
                    String deleteSql = "delete from " + oracleTable.getTableName();
                    deleteSql = deleteSql +  " where VEHICLEIND = '1'";
                    slaveOracleMapper.creatOracle(deleteSql);


                    // 开始获取相关表的数据
                    List<Map<String, Object>> dataList = null;
                    try{
                        dataList = masterOracleMapper.selectData(oracleTable.getTableNameSlave());
                        oracleTable.getDataList().addAll(dataList);
                    }catch (Exception e){
                        oracleTable.setExMessage("读取数据失败，此问题出现概率低，目前发现可能性有：1.数据获取代码存在问题。 2.当前表不属于当前用户下。");
                        extable.add(oracleTable);
                        continue;
                    }

                    System.out.println("数据存储量：" + dataList.size());
                    if (dataList.size()>0) {

                        System.out.println("开始存储");

                        // 形成添加语句
                        String creatInsert = creatInsertOracle(oracleTable);

                        // 执行存储数据
                        try {

                            slaveOracleMapper.creatOracle(creatInsert);

                        }catch (Exception e){

                            System.out.println(creatInsert);
                            System.out.println("存储方法一失败！！！执行方法2号");
                            e.printStackTrace();

                            try {

                                ConnectionUtils connectionUtils = new ConnectionUtils();
                                connectionUtils.sqlConnection(creatInsert,SlaveUrl,SlaveUsername,SlavePassword);

                            }catch (Exception e2){

                                oracleTable.setExMessage("数据存储失败："+creatInsert);
                                System.out.println(oracleTable.getExMessage());
                                extable.add(oracleTable);

                            }

                        }

                        System.out.println("存储完成");

                    }
                }

                System.out.println("数据表名：" + tableName + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());

            if (extable.size()>0) {
                System.out.println("以下失败表名");
                for (OracleTable s : extable) {
                    System.out.println(s.getTableName() + "原因是：" + s.getExMessage());
                }
            }

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }

        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost", 9200, "http")));

        for (int i = 0; i < 100; i++) {
            Map<String, Object> data = new HashMap<>();
            data.put("name", "我是"+i);
            data.put("age", i);
            IndexRequest request = new IndexRequest("your_index_name2")
                    .source(data, XContentType.JSON);
            IndexResponse response = client.index(request, RequestOptions.DEFAULT);
        }

        client.close();
    }

    ///////////////////////////////////////////////////////////////////////////
    // todo Oracle 转 Oracle (全量迁移)
    ///////////////////////////////////////////////////////////////////////////
    @Override
    public void OracleToOracleCompleteTableList(String dataBaseName,List<String> OracleTableList, boolean dataBool) {

        if (OracleTableList.size()<1) {
            OracleTableList = new ArrayList<>();
        }

        if (OracleTableList.size()>0) {

            List<OracleTable> extable = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;

            for (String tableName : OracleTableList) {

                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + tableName + " 开始");
                OracleTable oracleTable = selectOracle(dataBaseName,tableName);

                if (oracleTable.getFieldList().size()<1) {
                    oracleTable.setExMessage("此数据表无字段，无法迁移！！");
                    extable.add(oracleTable);
                    continue;
                }

                if (dataBool) {

                    Integer selectDataCount = 0;
                    try{
                        selectDataCount = masterOracleMapper.selectDataCount(dataBaseName+"."+oracleTable.getTableNameSlave());
                        System.out.println("数据量为：" + selectDataCount);
                    }catch (Exception e){
                        oracleTable.setExMessage("读取数据失败，此问题出现概率低，目前发现可能性有：1.数据获取代码存在问题。 2.当前表不属于当前用户下。");
                        extable.add(oracleTable);
                        continue;
                    }

                    int insertNum=10000;

                    // 开始获取相关表的数据
                    if (selectDataCount<=insertNum) {
                        System.out.println("直接存储");
                        List<Map<String, Object>>dataList = masterOracleMapper.selectData(dataBaseName+"."+oracleTable.getTableNameSlave());
                        oracleTable.getDataList().addAll(dataList);
                        System.out.println("数据存储量：" + dataList.size());
                        if (dataList.size()>0) {
                            System.out.println("开始存储");
                            // 形成添加语句
                            String creatInsert = creatInsertOracle(oracleTable);
                            // 执行存储数据
                            try {
                                slaveOracleMapper.creatOracle(creatInsert);
                            }catch (Exception e){
                                System.out.println(creatInsert);
                                System.out.println("存储方法一失败！！！执行方法2号");
                                e.printStackTrace();
                                try {
                                    ConnectionUtils connectionUtils = new ConnectionUtils();
                                    connectionUtils.sqlConnection(creatInsert,SlaveUrl,SlaveUsername,SlavePassword);
                                }catch (Exception e2){
                                    oracleTable.setExMessage("数据存储失败："+creatInsert);
                                    System.out.println(oracleTable.getExMessage());
                                    extable.add(oracleTable);
                                }
                            }
                            System.out.println("存储完成");
                        }
                    }
                    else {
                        System.out.println("批量存储");
                        final String tableNameEndFinal = dataBaseName+"."+oracleTable.getTableNameSlave();
                        BigDecimal one = new BigDecimal(selectDataCount);
                        BigDecimal two = new BigDecimal(insertNum);
                        BigDecimal divide = one.divide(two, RoundingMode.HALF_UP);
                        divide = divide.add(new BigDecimal(1));
                        System.out.println("单次数量为(可能出现次数比你们算的多1,2次，不会少，原因计算逻辑有问题，懒得改，凑乎用吧，否则自己搞去)：" + divide);
                        final int[] start = {0};
                        final int[] end = {start[0] + insertNum};
                        for (Integer i = 1; i <= Integer.valueOf(String.valueOf(divide.toString())); i++) {
                            String sql = "SELECT * FROM (SELECT a.*,ROWNUM RN FROM " + tableNameEndFinal + " a  WHERE ROWNUM <= " + end[0] + " ) WHERE RN >= " + start[0];
                            System.out.println("开始：" + start[0] + " 结束：" + end[0]);
                            oracleTable.setDataList(masterOracleMapper.creatOracleMap(sql));
                            System.out.println("数据存储量：" + oracleTable.getDataList().size());
                            if (oracleTable.getDataList().size()>0) {
                                System.out.println("开始存储");
                                // 形成添加语句
                                String creatInsert = creatInsertOracle(oracleTable);
                                // 执行存储数据
                                try {
                                    slaveOracleMapper.creatOracle(creatInsert);
                                }catch (Exception e){
                                    System.out.println("存储方法一失败！！！执行方法2号");
                                    e.printStackTrace();
                                    try {
                                        ConnectionUtils connectionUtils = new ConnectionUtils();
                                        connectionUtils.sqlConnection(creatInsert,SlaveUrl,SlaveUsername,SlavePassword);
                                    }catch (Exception e2){
                                        oracleTable.setExMessage("数据存储失败："+creatInsert);
                                        System.out.println(oracleTable.getExMessage());
                                        extable.add(oracleTable);
                                    }
                                }
                                System.out.println("存储完成");
                            }
                            start[0] = end[0] + 1;
                            end[0] = end[0] + insertNum;
                        }
                    }
                }

                System.out.println("数据表名：" + tableName + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());

            if (extable.size()>0) {
                System.out.println("以下失败表名");
                for (OracleTable s : extable) {
                    System.out.println(s.getTableName() + "原因是：" + s.getExMessage());
                }
            }

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }

    }


    ///////////////////////////////////////////////////////////////////////////
    // Oracle 转 Oracle (定时抽取投保单号)
    ///////////////////////////////////////////////////////////////////////////
    public void OracleToOracleIncrementCAppNo(){
        System.out.println("开始获取时间范围");

        List<String> selectDates = new ArrayList<>();

        selectDates.add("2000-10-01");
        selectDates.add("2001-01-01");
        selectDates.add("2001-04-01");
        selectDates.add("2001-07-01");
        selectDates.add("2001-10-01");
        selectDates.add("2002-01-01");
        selectDates.add("2002-04-01");
        selectDates.add("2002-07-01");
        selectDates.add("2002-10-01");
        selectDates.add("2003-01-01");
        selectDates.add("2003-04-01");
        selectDates.add("2003-07-01");
        selectDates.add("2003-10-01");
        selectDates.add("2004-01-01");
        selectDates.add("2004-04-01");
        selectDates.add("2004-07-01");
        selectDates.add("2004-10-01");
        selectDates.add("2005-01-01");
        selectDates.add("2005-04-01");
        selectDates.add("2005-07-01");
        selectDates.add("2005-10-01");
        selectDates.add("2006-01-01");
        selectDates.add("2006-04-01");
        selectDates.add("2006-07-01");
        selectDates.add("2006-10-01");
        selectDates.add("2007-01-01");
        selectDates.add("2007-04-01");
        selectDates.add("2007-07-01");
        selectDates.add("2007-10-01");
        selectDates.add("2008-01-01");
        selectDates.add("2008-04-01");
        selectDates.add("2008-07-01");
        selectDates.add("2008-10-01");
        selectDates.add("2009-01-01");
        selectDates.add("2009-04-01");
        selectDates.add("2009-07-01");
        selectDates.add("2009-10-01");
        selectDates.add("2010-01-01");
        selectDates.add("2010-04-01");
        selectDates.add("2010-07-01");
        selectDates.add("2010-10-01");
        selectDates.add("2011-01-01");
        selectDates.add("2011-04-01");
        selectDates.add("2011-07-01");
        selectDates.add("2011-10-01");
        selectDates.add("2012-01-01");
        selectDates.add("2012-04-01");
        selectDates.add("2012-07-01");
        selectDates.add("2012-10-01");
        selectDates.add("2013-01-01");
        selectDates.add("2013-04-01");
        selectDates.add("2013-07-01");
        selectDates.add("2013-10-01");
        selectDates.add("2014-01-01");
        selectDates.add("2014-04-01");
        selectDates.add("2014-07-01");
        selectDates.add("2014-10-01");
        selectDates.add("2015-01-01");
        selectDates.add("2015-04-01");
        selectDates.add("2015-07-01");
        selectDates.add("2015-10-01");
        selectDates.add("2016-01-01");
        selectDates.add("2016-04-01");
        selectDates.add("2016-07-01");
        selectDates.add("2016-10-01");
        selectDates.add("2017-01-01");
        selectDates.add("2017-04-01");
        selectDates.add("2017-07-01");
        selectDates.add("2017-10-01");
        selectDates.add("2018-01-01");
        selectDates.add("2018-04-01");
        selectDates.add("2018-07-01");
        selectDates.add("2018-10-01");
        selectDates.add("2019-01-01");
        selectDates.add("2019-04-01");
        selectDates.add("2019-07-01");
        selectDates.add("2019-10-01");
        selectDates.add("2020-01-01");
        selectDates.add("2020-04-01");
        selectDates.add("2020-07-01");
        selectDates.add("2020-10-01");
        selectDates.add("2021-01-01");
        selectDates.add("2021-04-01");
        selectDates.add("2021-07-01");
        selectDates.add("2021-10-01");
        selectDates.add("2022-01-01");
        selectDates.add("2022-04-01");
        selectDates.add("2022-07-01");
        selectDates.add("2022-10-01");
        selectDates.add("2023-01-01");
        selectDates.add("2023-04-01");
        selectDates.add("2023-07-01");
        selectDates.add("2023-10-01");
        selectDates.add("2024-01-01");
        selectDates.add("2024-04-01");
        selectDates.add("2024-07-01");
        selectDates.add("2024-10-01");
        selectDates.add("2025-01-01");
        selectDates.add("2025-04-01");
        selectDates.add("2025-07-01");

        if (selectDates.size()<1) {
            System.out.println("没有时间范围数据");
            return;
        }

        OracleTable oracleTable = selectOracle(MasterDatabaseName,"WEB_MIGRATE_APPNO");
        if (oracleTable.getFieldList().size()<1) {
            System.out.println("此数据表无字段，无法迁移！！");
            return;
        }

        for (int i = 0; i < selectDates.size(); i++) {
            // 开始时间 结束时间
            String startDate="";
            String endDate="";
            startDate= selectDates.get(i);
            try {
                endDate= selectDates.get(i+1);
            }catch (Exception e) {
                break;
            }
            System.out.println("=============================");
            System.out.println("提取"+startDate+"到"+endDate+"的数据开始");

            String sql = "BEGIN\n" +
                    "  MIGRATE_APPNO('"+startDate+"', '"+endDate+"');\n" +
                    "END";
            System.out.println(sql);
            try {
                slaveOracleMapper.creatOracle(sql);
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("执行失败,跳过");
            }

            System.out.println("提取"+startDate+"到"+endDate+"的数据结束");
            System.out.println("=============================");
        }

    }

    ///////////////////////////////////////////////////////////////////////////
    // todo Oracle 转 Oracle (增量迁移)
    ///////////////////////////////////////////////////////////////////////////
    public void OracleToOracleIncrementTableList(List<Map<String,String>> OracleTableList){

        if (OracleTableList.size()<1) {
            OracleTableList = new ArrayList<>();
        }

        // 昨天日期
        LocalDate today = LocalDate.now();
        LocalDate yesterday = today.minusDays(1);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String yesterdayFormatted = yesterday.format(formatter);
        String todayFormatted = today.format(formatter);
        System.out.println("昨天日期：" + yesterdayFormatted);

        if (OracleTableList.size()>0) {
            List<OracleTable> extable = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;

            for (Map<String,String> tableOneMap : OracleTableList) {

                String tableName = tableOneMap.get("table");
                String id = tableOneMap.get("id");
                String way = tableOneMap.get("way");
                String inc_field = tableOneMap.get("inc_field");
                String n_table = tableOneMap.get("n_table");

                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + tableName + " 开始");
                OracleTable oracleTable = selectOracle(MasterDatabaseName,tableName);

                if (oracleTable.getFieldList().size()<1) {
                    oracleTable.setExMessage("此数据表无字段，无法迁移！！");
                    extable.add(oracleTable);
                    continue;
                }
                if (n_table!=null) {
                    if (!n_table.equals("null")) {
                        oracleTable.setTableNameSlave(n_table);
                    }
                }
                System.out.println("目标表："+oracleTable.getTableNameSlave());


                String masterTableName = MasterDatabaseName + "." + oracleTable.getTableName();
//                if (way.equals("all")) {
//                    System.out.println("全量处理");
//                    masterTableName = masterTableName;
//                }
//                else if (way.equals("increment")) {
//                    System.out.println("增量处理");
//
//                    if (inc_field.equals("T_UPD_TM")) {
//                        masterTableName = masterTableName +
//                                " WHERE "+inc_field+">=TO_DATE('"+yesterdayFormatted+"', 'YYYY-MM-DD') " +
//                                "AND "+inc_field+"<TO_DATE('"+todayFormatted+"', 'YYYY-MM-DD')";
//                    }
//                }

                StringBuffer stringBufferEnd = new StringBuffer();
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-02', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-02', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-03', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-03', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-04', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-04', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-05', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-05', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-06', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-06', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-07', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-07', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-08', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-08', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-09', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-09', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-10', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-10', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-11', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-11', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-12', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-12', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-13', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-13', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-14', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-14', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-15', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-15', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-16', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-16', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-17', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-17', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-18', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-18', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-19', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-19', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-20', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-20', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-21', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-21', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-22', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-22', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-23', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-23', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-24', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-24', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-25', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-25', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-26', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-26', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-27', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-27', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-28', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-28', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-29', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-29', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-30', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-30', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2024-12-31', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2024-12-31', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-01', 'YYYY-MM-DD');");

                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-02', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-02', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-03', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-03', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-04', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-04', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-05', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-05', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-06', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-06', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-07', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-07', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-08', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-08', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-09', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-09', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-10', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-10', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-11', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-11', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-12', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-12', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-13', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-13', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-14', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-14', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-15', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-15', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-16', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-16', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-17', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-17', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-18', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-18', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-19', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-19', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-20', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-20', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-21', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-21', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-22', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-22', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-23', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-23', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-24', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-24', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-25', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-25', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-26', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-26', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-27', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-27', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-28', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-28', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-29', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-29', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-30', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-30', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-01-31', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-01-31', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-01', 'YYYY-MM-DD');");

                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-02', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-02', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-03', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-03', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-04', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-04', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-05', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-05', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-06', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-06', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-07', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-07', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-08', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-08', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-09', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-09', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-10', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-10', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-11', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-11', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-12', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-12', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-13', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-13', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-14', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-14', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-15', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-15', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-16', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-16', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-17', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-17', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-18', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-18', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-19', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-19', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-20', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-20', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-21', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-21', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-22', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-22', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-23', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-23', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-24', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-24', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-25', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-25', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-26', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-26', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-27', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-27', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-02-28', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-02-28', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-01', 'YYYY-MM-DD');");

                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-02', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-02', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-03', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-03', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-04', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-04', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-05', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-05', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-06', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-06', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-07', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-07', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-08', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-08', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-09', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-09', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-10', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-10', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-11', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-11', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-12', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-12', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-13', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-13', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-14', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-14', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-15', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-15', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-16', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-16', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-17', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-17', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-18', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-18', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-19', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-19', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-20', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-20', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-21', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-21', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-22', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-22', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-23', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-23', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-24', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-24', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-25', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-25', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-26', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-26', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-27', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-27', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-28', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-28', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-29', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-29', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-30', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-30', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-03-31', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-03-31', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-01', 'YYYY-MM-DD');");

                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-02', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-02', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-03', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-03', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-04', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-04', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-05', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-05', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-06', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-06', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-07', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-07', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-08', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-08', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-09', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-09', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-10', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-10', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-11', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-11', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-12', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-12', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-13', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-13', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-14', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-14', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-15', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-15', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-16', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-16', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-17', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-17', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-18', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-18', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-19', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-19', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-20', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-20', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-21', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-21', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-22', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-22', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-23', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-23', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-24', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-24', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-25', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-25', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-26', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-26', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-27', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-27', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-28', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-28', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-29', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-29', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-04-30', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-04-30', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-01', 'YYYY-MM-DD');");

                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-02', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-02', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-03', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-03', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-04', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-04', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-05', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-05', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-06', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-06', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-07', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-07', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-08', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-08', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-09', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-09', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-10', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-10', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-11', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-11', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-12', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-12', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-13', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-13', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-14', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-14', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-15', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-15', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-16', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-16', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-17', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-17', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-18', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-18', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-19', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-19', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-20', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-20', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-21', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-21', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-22', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-22', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-23', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-23', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-24', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-24', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-25', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-25', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-26', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-26', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-27', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-27', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-28', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-28', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-29', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-29', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-30', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-30', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-05-31', 'YYYY-MM-DD');");
                stringBufferEnd.append(" WHERE "+inc_field+">=TO_DATE('2025-05-31', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('2025-06-01', 'YYYY-MM-DD');");

                for (String sql : stringBufferEnd.toString().split(";")) {
                    sql = masterTableName + sql;
                    System.out.println("读取数据");
                    System.out.println(sql);

                    // 记录日志
                    WebMigrateOtoLog webMigrateOtoLog = new WebMigrateOtoLog();
                    webMigrateOtoLog.setTable(oracleTable.getTableName());
                    webMigrateOtoLog.setSql(sql);
                    webMigrateOtoLog.setType("1");
                    slaveOracleMapper.insertWebMigrateOtoLog(webMigrateOtoLog);

                    List<Map<String, Object>> dataList = masterOracleMapper.selectData(sql);
                    oracleTable.setDataList(dataList);
                    System.out.println("数据存储量：" + oracleTable.getDataList().size());
                    if (dataList.size()>0) {

                        // 处理主键问题
                        String[] idSpl = id.split(",");
                        for (String string : idSpl) {
                            oracleTable.getFieldKeyList().add(string);
                        }

                        System.out.println("组合存储数据");
                        List<List<Map<String, Object>>> lists = splitList(oracleTable.getDataList());
                        boolean b = false;
                        int a = 1;
                        if (way.equals("all")) {
                            String dropsql = "TRUNCATE TABLE "+oracleTable.getDataBaseName() + ".\"" + oracleTable.getTableNameSlave() + "\"";
                            System.out.println("执行清空");
                            slaveOracleMapper.creatOracle(dropsql);
                        }
                        else {
                            for (List<Map<String, Object>> list : lists) {
                                System.out.println("删除组合批次："+lists.size()+"/"+a+++",当前数据量："+list.size());
                                System.out.println("组合主键的删除语句");
                                String creatIdOracle = creatIdOracle(oracleTable.getDataBaseName(), oracleTable.getTableNameSlave(), oracleTable.getFieldKeyList(), list);
                                try {
                                    System.out.println("执行删除");
                                    slaveOracleMapper.creatOracle(creatIdOracle);
                                }catch (Exception e){
                                    System.out.println("删除失败");
                                    b = true;
                                    webMigrateOtoLog = new WebMigrateOtoLog();
                                    webMigrateOtoLog.setTable(oracleTable.getTableName());
                                    webMigrateOtoLog.setSql(sql);
                                    webMigrateOtoLog.setType("3");
                                    slaveOracleMapper.insertWebMigrateOtoLog(webMigrateOtoLog);
                                    break;
                                }
                            }
                        }


                        if (b) {
                            continue;
                        }

                        a = 1;
                        for (List<Map<String, Object>> list : lists) {
                            System.out.println("存储组合批次："+lists.size()+"/"+a+++",当前数据量："+list.size());
                            String creatInsert = creatInsertOracle2(oracleTable.getDataBaseName(), oracleTable.getTableNameSlave(), oracleTable.getFieldList(), list);
                            // 执行存储数据
                            try {
                                System.out.println("执行存储");
                                slaveOracleMapper.creatOracle(creatInsert);
                            }catch (Exception e){
                                System.out.println("存储失败");
                                b = true;
                                webMigrateOtoLog = new WebMigrateOtoLog();
                                webMigrateOtoLog.setTable(oracleTable.getTableName());
                                webMigrateOtoLog.setSql(sql);
                                webMigrateOtoLog.setType("3");
                                slaveOracleMapper.insertWebMigrateOtoLog(webMigrateOtoLog);
                                break;
                            }
                        }

                        if (b) {
                            continue;
                        }

                        webMigrateOtoLog = new WebMigrateOtoLog();
                        webMigrateOtoLog.setTable(oracleTable.getTableName());
                        webMigrateOtoLog.setSql(sql);
                        webMigrateOtoLog.setType("2");
                        slaveOracleMapper.insertWebMigrateOtoLog(webMigrateOtoLog);
                        System.out.println("存储完成");
                    }
                }
                System.out.println("数据表名：" + tableName + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());
            if (extable.size()>0) {
                System.out.println("以下失败表名");
                for (OracleTable s : extable) {
                    System.out.println(s.getTableName());
                }
            }

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }
    }

    public void OracleToOracleIncrementTableList2(List<Map<String,String>> OracleTableList){

        if (OracleTableList.size()<1) {
            OracleTableList = new ArrayList<>();
        }

        // 昨天日期
        LocalDate today = LocalDate.now();
        LocalDate yesterday = today.minusDays(1);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String yesterdayFormatted = yesterday.format(formatter);
        String todayFormatted = today.format(formatter);
        System.out.println("昨天日期：" + yesterdayFormatted);

        if (OracleTableList.size()>0) {
            List<OracleTable> extable = new ArrayList<>();
            List<Map<String,String>> extableMap = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;

            for (Map<String,String> tableOneMap : OracleTableList) {

                String tableName = tableOneMap.get("table");
                String id = tableOneMap.get("id");
                String way = tableOneMap.get("way");
                String inc_field = tableOneMap.get("inc_field");
                String n_table = tableOneMap.get("n_table");

                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + tableName + " 开始");
                OracleTable oracleTable = selectOracle(MasterDatabaseName,tableName);
                if (oracleTable.getFieldList().size()<1) {
                    oracleTable.setExMessage("此数据表无字段，无法迁移！！");
                    extable.add(oracleTable);
                    continue;
                }
                if (n_table!=null) {
                    oracleTable.setTableNameSlave(n_table);
                }
                System.out.println("目标表："+oracleTable.getTableNameSlave());


                String masterTableName = MasterDatabaseName + "." + oracleTable.getTableName();
                if (way.equals("all")) {
                    System.out.println("全量处理");
                    masterTableName = masterTableName;
                }
                else if (way.equals("increment")) {
                    System.out.println("增量处理");
                    if (inc_field.equals("T_UPD_TM")) {
                        masterTableName = masterTableName +
                                " WHERE "+inc_field+">=TO_DATE('"+yesterdayFormatted+"', 'YYYY-MM-DD') " +
                                "AND "+inc_field+"<TO_DATE('"+todayFormatted+"', 'YYYY-MM-DD')";
                    }
                    else if (inc_field.equals("T_CANCEL_TM")) {
                        masterTableName = masterTableName +
                                " WHERE "+inc_field+">=TO_DATE('"+yesterdayFormatted+"', 'YYYY-MM-DD') " +
                                "AND "+inc_field+"<TO_DATE('"+todayFormatted+"', 'YYYY-MM-DD')";
                    }
                }


                System.out.println("读取数据");
                System.out.println(masterTableName);
                List<Map<String, Object>> dataList = new ArrayList<>();
                try {
                    dataList = masterOracleMapper.selectData(masterTableName);
                }catch (Exception e){
                    e.printStackTrace();
                    oracleTable.setExMessage("数据读取失败");
                    extable.add(oracleTable);
                    extableMap.add(tableOneMap);
                    continue;
                }
                oracleTable.setDataList(dataList);
                System.out.println("数据存储量：" + oracleTable.getDataList().size());
                if (dataList.size()>0) {

                    // 处理主键问题
                    String[] idSpl = id.split(",");
                    for (String string : idSpl) {
                        oracleTable.getFieldKeyList().add(string);
                    }

                    System.out.println("组合存储数据");
                    List<List<Map<String, Object>>> lists = splitList(oracleTable.getDataList());
                    int a = 1;
                    if (way.equals("all")) {
                        String dropsql = "TRUNCATE TABLE "+oracleTable.getDataBaseName() + ".\"" + oracleTable.getTableNameSlave() + "\"";
                        System.out.println("执行清空");
                        slaveOracleMapper.creatOracle(dropsql);
                    }
                    else {
                        for (List<Map<String, Object>> list : lists) {
                            System.out.println("删除组合批次："+lists.size()+"/"+a+++",当前数据量："+list.size());
                            System.out.println("组合主键的删除语句");
                            String creatIdOracle = creatIdOracle(oracleTable.getDataBaseName(), oracleTable.getTableNameSlave(), oracleTable.getFieldKeyList(), list);
                            try {
                                System.out.println("执行删除");
                                slaveOracleMapper.creatOracle(creatIdOracle);
                            }catch (Exception e){
                                System.out.println("删除方法一失败！！！");
                                oracleTable.setExMessage("数据删除失败");
                                extable.add(oracleTable);
                                extableMap.add(tableOneMap);
                                continue;
                            }
                        }
                    }


                    a = 1;
                    for (List<Map<String, Object>> list : lists) {
                        System.out.println("存储组合批次："+lists.size()+"/"+a+++",当前数据量："+list.size());
                        String creatInsert = creatInsertOracle2(oracleTable.getDataBaseName(), oracleTable.getTableNameSlave(), oracleTable.getFieldList(), list);
                        // 执行存储数据
                        try {
                            System.out.println("执行存储");
                            slaveOracleMapper.creatOracle(creatInsert);
                        }catch (Exception e){
                            System.out.println("存储方法一失败！！！");
                            oracleTable.setExMessage("数据存储失败");
                            extableMap.add(tableOneMap);
                            extable.add(oracleTable);
                        }
                    }

                    if (oracleTable.getTableNameSlave().equals("WEB_CLM_MAIN_END")) {
                        // 留意记录删除的主键id用于补救其他映射表的数据
                        String sql = "DELETE FROM WEB_CLM_MAIN_END WHERE C_CLM_STS != '15'";
                        slaveOracleMapper.creatOracle(sql);
                    }


                    System.out.println("存储完成");
                }

                try {
                    // 多线程验证做数据校验
                    Thread thread1 = new Thread(()->{
                        SC(oracleTable, yesterdayFormatted,todayFormatted,inc_field,id);
                    });
                    thread1.start();
                }catch (Exception e){
                    oracleTable.setExMessage("数据核验发起失败");
                }

                System.out.println("数据表名：" + tableName + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());
            // 插入日志
            String SQL = "INSERT INTO PCISV6.MIGRATION_LOG_END (PROCEDURE_NAME,MESSAGETIME,STATUSS) VALUES ('备份-中转','"+yesterdayFormatted+"','1')";
            slaveOracleMapper.creatOracle(SQL);

            if (extable.size()>0) {
                System.out.println("以下失败表名");
                for (OracleTable s : extable) {
                    System.out.println(s.getTableName());
                }
            }
            // 对失败的表进行二次处理
//            extableMap

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }
    }

    public void SC(OracleTable oracleTable, String yesterdayFormatted,String todayFormatted,String inc_field,String id) {
//        WEB_CLM_MAIN
//        WEB_CLM_ESTMT
//        WEB_CLM_BANK
//        WEB_CLM_PEND_DTL 未决
//        WEB_PLY_INSURED
//        WEB_PAY_CONFIRM_INFO
//        WEB_CLMNV_SRVY

        if (oracleTable.getTableNameSlave().equals("WEB_CLM_FEELIST_ADJUST")
//                ||oracleTable.getTableNameSlave().equals("WEB_CLM_BANK")
        ) {
            LocalDate today = LocalDate.now();
            DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy");
            String noeY = today.format(formatter2);
            int noeYint = Integer.parseInt(noeY);
            for (int years = (noeYint-5); years <noeYint ; years++) {
                List<String> stringBufferEnd = new ArrayList<>();
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-01-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-02-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-02-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-03-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-03-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-04-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-04-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-05-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-05-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-06-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-06-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-07-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-07-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-08-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-08-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-09-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-09-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-10-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-10-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-11-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-11-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+years+"-12-01', 'YYYY-MM-DD')");
                stringBufferEnd.add(" "+inc_field+">=TO_DATE('"+years+"-12-01', 'YYYY-MM-DD') AND "+inc_field+"<TO_DATE('"+(years+1)+"-01-01', 'YYYY-MM-DD')");

                for (String sqlWhere : stringBufferEnd) {
                    String sql = "SELECT "+id+" FROM "+oracleTable.getDataBaseName()+".\""+oracleTable.getTableNameSlave()+"\" WHERE "+sqlWhere;
                    System.out.println(sql);
                    List<Map<String, Object>> mapList = slaveOracleMapper.creatOracleMap(sql);
                    if (mapList.size()>0) {
                        StringBuffer stringBuffer = new StringBuffer();
                        stringBuffer.append("WITH desired_ids AS (\n");
                        for (int i = 0; i < mapList.size(); i++) {
                            if(i==0){
                                stringBuffer.append("SELECT '"+mapList.get(i).get(id)+"' AS "+id+" FROM dual\n");
                            }
                            else {
                                stringBuffer.append("UNION ALL SELECT '"+mapList.get(i).get(id)+"' AS "+id+" FROM dual\n");
                            }
                        }
                        stringBuffer.append(")\n");
                        stringBuffer.append("SELECT "+id+"\n" +
                                "FROM desired_ids\n" +
                                "WHERE "+id+" NOT IN (SELECT "+id+" FROM "+oracleTable.getTableName()+")");
                        List<Map<String, Object>> delete = masterOracleMapper.creatOracleMap(stringBuffer.toString());
                        System.out.println("删除数据有："+delete.size());
                        if (delete.size()>0) {
                            try {
                                // 多线程验证做数据校验
                                Thread thread1 = new Thread(()->{
                                    SC2(oracleTable, delete, id);
                                });
                                thread1.start();
                            }catch (Exception e){
                                oracleTable.setExMessage("数据删除发起失败");
                            }
                        }
                    }

                }
            }
        }

        try {
            // 多线程验证做数据校验
            Thread thread1 = new Thread(()->{
                JY(oracleTable, yesterdayFormatted,todayFormatted);
            });
            thread1.start();
        }catch (Exception e){
            oracleTable.setExMessage("数据核验发起失败");
        }
    }

    public void SC2(OracleTable oracleTable,List<Map<String, Object>> delete,String id){
        try {
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append("DELETE FROM "+oracleTable.getDataBaseName()+".\""+oracleTable.getTableNameSlave()+"\" WHERE "+id+" IN (");
            for (int i = 0; i < delete.size(); i++) {
                if (i==0) {
                    stringBuffer.append("'"+delete.get(i).get(id)+"'");
                }
                else{
                    stringBuffer.append(",'"+delete.get(i).get(id)+"'");
                }
            }
            stringBuffer.append(")");
            slaveOracleMapper.creatOracle(stringBuffer.toString());
            System.out.println("删除数据成功"+delete.size());
        }catch (Exception e){
            oracleTable.setExMessage("数据删除失败");
        }
    }


    public void JY(OracleTable oracleTable, String yesterdayFormatted,String todayFormatted){
        // WHERE T_UPD_TM<TO_DATE('2025-05-29', 'YYYY-MM-DD')
        System.out.println("开始数据核验");
        String sql = "SELECT COUNT(1) ";

        // 根据从表名称，添加不同的字段
        if (oracleTable.getTableNameSlave().equals("WEB_CLM_ACCDNT")) {
            sql = sql + ",SUM(N_RPT_AMT),SUM(N_DISASTER_RPT_AMT),SUM(N_NOGAIN_RPT_AMT),SUM(C_CYQMONEY)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLMNV_RGST")) {
            sql = sql + ",SUM(N_PAY_AMT),SUM(N_FEE_AMT)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_MAIN")) {
            sql = sql + ",SUM(N_AMT),SUM(N_PREPAY),SUM(N_PREPAY),SUM(N_PP_AMT),SUM(N_CHASE_AMT),SUM(N_SELF_AMT),SUM(N_PXY_AMT),SUM(N_EXG_AMT),SUM(N_PAY_AMT),SUM(N_COIN_APPO),SUM(N_CLM_FEE),SUM(N_GUESS_AMT),SUM(N_HLP_FEE),SUM(N_PROXY_SRV_FEE),SUM(N_SRV_FEE),SUM(N_ESTMT),SUM(N_ESTMT_RMB),SUM(N_PREPAY_RMB),SUM(N_PAY_RMB),SUM(N_CLMFEE_RMB),SUM(N_COIN_APPO_RMB),SUM(N_B_AMT)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_ESTMT")) {
            sql = sql + ",SUM(N_LOSS_TGT),SUM(N_LOSS_INJU),SUM(N_LOSS),SUM(N_LOSS_RMB),SUM(N_CHKLOSS),SUM(N_CHKLOSS_RMB),SUM(N_HELP),SUM(N_HELP_RMB),SUM(N_CHKHELP),SUM(N_CHKHELP_RMB),SUM(N_CLMFEE),SUM(N_CLMFEE_RMB),SUM(N_CHKCLMFEE),SUM(N_CHKCLMFEE_RMB),SUM(N_ESTMT),SUM(N_ESTMT_RMB),SUM(N_CHKESTMT),SUM(N_CHKESTMT_RMB),SUM(N_REMAIN),SUM(N_REMAIN_RMB),SUM(N_LAW),SUM(N_LAW_RMB),SUM(N_LOSS_INJU_RMB),SUM(N_CHK_LOSS_INJU),SUM(N_CHK_LOSS_INJU_RMB),SUM(N_CHKREMAINRMB),SUM(N_CHKLAWRMB),SUM(N_CHKREMAIN),SUM(N_CHKLAW)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_COINAPPO")) {
            sql = sql + ",SUM(N_APPO_PAY),SUM(N_APPO_PAID),SUM(N_FEE_PAY),SUM(N_TOTAL_PAY),SUM(N_TOTAL_FEE)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLMNV_SRVY")) {
            sql = sql + ",SUM(C_CYQMONEY),SUM(C_CBMONEY),SUM(C_CTAXMONEY),SUM(C_CFXMONEY),SUM(C_CZRGIVEMONEY),SUM(C_CZRGIVETAX),SUM(C_CDBMOEY),SUM(T_REFUND_LOS_AMT),SUM(N_BUSINESS_AMOUNT)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_RECOVER_ENDCASE")) {
            sql = sql + ",SUM(N_RECOVER_THIS),SUM(N_RECOVER_RMB),SUM(N_RECOVER_FEE),SUM(N_RECOVER_FEE_RMB),SUM(N_RECOVER)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_RECOVER_RGST")) {
            sql = sql + ",SUM(N_RECOVER_RMB),SUM(N_RECOVER_FEE_RMB),SUM(N_RECOVER_RGST)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_ADJUST")) {
            sql = sql + ",SUM(N_LOSSPAY),SUM(N_LOSSPAY_RMB),SUM(N_HELP),SUM(N_HELP_RMB),SUM(N_CLMFEE),SUM(N_CLMFEE_RMB),SUM(N_REALPAY),SUM(N_REALPAY_RMB),SUM(N_PAY),SUM(N_PAY_RMB),SUM(N_PRE_PAY_RMB),SUM(N_PRE_PAY),SUM(N_REMAIN),SUM(N_REMAIN_RMB),SUM(N_LAW),SUM(N_LAW_RMB),SUM(N_PRE_PAY_FREE_RMB),SUM(N_PRE_PAY_FREE),SUM(N_ACCOMPAY),SUM(N_ACCOMPAY_RMB),SUM(N_PAY_SHARE),SUM(N_PAY_SHARE_RMB),SUM(N_CLMFEE_SHARE),SUM(N_REALPAY_SHARE),SUM(N_REALPAY_SHARE_RMB),SUM(N_LAW_SHARE),SUM(N_LAW_SHARE_RMB),SUM(N_INDEMNITY_PROPERTY_AMT),SUM(N_INVALID_PROPERTY_AMT)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_BANK")) {
            sql = sql + ",SUM(N_AMT),SUM(N_BENF_PROP)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_PEND")) {
            sql = sql + ",SUM(N_THIS_PEND_AMT),SUM(N_THIS_DTMD_AMT),SUM(N_PEND_AMT),SUM(N_DTMD_AMT),SUM(N_THIS_FEE_PEND_AMT),SUM(N_THIS_FEE_DTMD_AMT),SUM(N_FEE_PEND_AMT),SUM(N_FEE_DTMD_AMT),SUM(N_CLMFEE),SUM(N_PEND_A_AMT),SUM(N_DTMD_S_AMT),SUM(N_B_AMT),SUM(N_OWN_SHARE_RATIO),SUM(N_ORIG_CLM_AMT),SUM(N_DUE_AMT),SUM(N_PEND_AMT_SUM),SUM(N_FEE_PEND_AMT_SUM),SUM(N_DTMD_AMT_SUM),SUM(N_FEE_DTMD_AMT_SUM)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_PEND_DTL")) {
            sql = sql + ",SUM(N_THIS_PEND_AMT),SUM(N_THIS_DTMD_AMT),SUM(N_PEND_AMT),SUM(N_DTMD_AMT)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_FEELIST_ADJUST")) {
            sql = sql + ",SUM(N_CLMFEE),SUM(N_CLMFEE_SHARE)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLM_CHECKCLM")) {
            sql = sql + ",SUM(N_APP_AMT)";
        }
        else if (oracleTable.getTableNameSlave().equals("WEB_CLMNV_PREPAY")) {
            sql = sql + ",SUM(N_THIS_PREPAY),SUM(N_THIS_PREPAY_SHARE),SUM(N_THIS_PREFREE_SHARE)";
        }

        // 拼接表名
        sql = sql + " FROM "+oracleTable.getDataBaseName() + ".\"" + oracleTable.getTableNameSlave() + "\"";

        // 根据从表名称，添加不同的条件
        if (oracleTable.getTableNameSlave().equals("WEB_CLMNV_RGST")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_ESTMT")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_MAIN")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_MAIN_END")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_CHECKCLM")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_DOCINFO")
                || oracleTable.getTableNameSlave().equals("WEB_CLMNV_SRVY")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_ADJUST")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_BANK")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_PEND")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_FEELIST_ADJUST")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_PEND_DTL")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_ACCDNT")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_RPT")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_RPT_REMARKS")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_DSPT_DTL")
                || oracleTable.getTableNameSlave().equals("WEB_CLM_DSPT")

                || oracleTable.getTableNameSlave().equals("WEB_PLY_CARGO")
                || oracleTable.getTableNameSlave().equals("WEB_ILOG_FEE_INFO")
                || oracleTable.getTableNameSlave().equals("WEB_UNDR_OPN")
                || oracleTable.getTableNameSlave().equals("WEB_PLY_CARGO_LIST")
                || oracleTable.getTableNameSlave().equals("WEB_PLY_ACCTINFO")
                || oracleTable.getTableNameSlave().equals("MM_CHARGEDETAIL_TI")
                || oracleTable.getTableNameSlave().equals("WEB_PLY_TGT")
                || oracleTable.getTableNameSlave().equals("MM_POLICY_TI")
                || oracleTable.getTableNameSlave().equals("MM_PAY_PLAN_TI")
                || oracleTable.getTableNameSlave().equals("WEB_PLY_TGT_OBJ")
                || oracleTable.getTableNameSlave().equals("MM_POLICYLIST_TI")
                || oracleTable.getTableNameSlave().equals("WEB_PLY_BASE")
                || oracleTable.getTableNameSlave().equals("WEB_PLY_INSURED")
                || oracleTable.getTableNameSlave().equals("WEB_PLY_APPLICANT")
                || oracleTable.getTableNameSlave().equals("WEB_PLY_CI")


                || oracleTable.getTableNameSlave().equals("WEB_PRN_INFO")
                || oracleTable.getTableNameSlave().equals("WEB_PLY_PRJ_REL")
                || oracleTable.getTableNameSlave().equals("WEB_PLY_ENT_TGT")
                || oracleTable.getTableNameSlave().equals("WEB_EDR_CMP_ITEM")
                || oracleTable.getTableNameSlave().equals("WEB_PAY_CONFIRM_INFO")
        ) {
            sql = sql + " WHERE T_UPD_TM<TO_DATE('"+todayFormatted+"', 'YYYY-MM-DD')";
        }

        // 创建两个线程，分别执行备份库和迁移库的查询
        int threadCount = 2;
        CountDownLatch latch = new CountDownLatch(threadCount);
        final String[] oneData = {""};
        final String[] twoData = {""};
        final List<Map<String, Object>>[] listOne = new List[]{new ArrayList<>()};
        final List<Map<String, Object>>[] listtwo = new List[]{new ArrayList<>()};
        String finalSql = sql;
        Thread thread1 = new Thread(()->{
            try {
                String replaceAll = finalSql;
                if (oracleTable.getTableNameSlave().equals("WEB_CLM_MAIN_END")) {
                    replaceAll = finalSql.replaceAll("WEB_CLM_MAIN_END", "WEB_CLM_MAIN");
                    replaceAll = replaceAll + " AND C_CLM_STS = '15'";
                }
                System.out.println("备份库："+replaceAll);
                List<Map<String,Object>> list = masterOracleMapper.creatOracleMap(replaceAll);
                listOne[0] = list;
                String jsonString = JSON.toJSONString(list);
                oneData[0] = jsonString;
                System.out.println("备份库："+jsonString);
            }catch (Exception e){
                System.out.println("备份库失败");
                e.printStackTrace();
            }
            latch.countDown();
        });
        thread1.start();


        Thread thread2 = new Thread(()->{
            try {
                System.out.println("中转库："+finalSql);
                List<Map<String,Object>> list = slaveOracleMapper.creatOracleMap(finalSql);
                listtwo[0] = list;
                String jsonString = JSON.toJSONString(list);
                twoData[0] = jsonString;
                System.out.println("中转库："+jsonString);
            }catch (Exception e){
                System.out.println("中转库失败");
                e.printStackTrace();
            }
            latch.countDown();
        });
        thread2.start();
        try {
            // 等待所有线程执行完毕
            latch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        String SQL = "";
        sql=sql.replaceAll("'", "''");
        if (oneData[0].equals(twoData[0])) {
            System.out.println("数据一致");
            SQL = "INSERT INTO PCISV6.MIGRATION_LOG_HAND (TABLES,MESSAGETIME,MESSAGETEND) VALUES ('"+sql+"','"+yesterdayFormatted+"','"+oneData[0]+"&&"+twoData[0]+"=="+"数据一致"+"')";
        }
        else {
            System.out.println("数据不一致");
            SQL = "INSERT INTO PCISV6.MIGRATION_LOG_HAND (TABLES,MESSAGETIME,MESSAGETEND) VALUES ('"+sql+"','"+yesterdayFormatted+"','"+oneData[0]+"&&"+twoData[0]+"=="+"数据不一致"+"')";
        }
        slaveOracleMapper.creatOracle(SQL);
        System.out.println("数据核验完成");
    }


    public static List<List<Map<String, Object>>> splitList(List<Map<String, Object>> originalList) {
        List<List<Map<String, Object>>> result = new ArrayList<>();
        int batchSize = 10000;
        for (int i = 0; i < originalList.size(); i += batchSize) {
            int toIndex = Math.min(i + batchSize, originalList.size());
            result.add(new ArrayList<>(originalList.subList(i, toIndex)));
        }
        return result;
    }


    public void BaseTONewTable(List<Map<String,String>> OracleTableList){
        if (OracleTableList.size()>0) {
            List<OracleTable> extable = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;

            for (Map<String,String> tableOneMap : OracleTableList) {

                String table_load = tableOneMap.get("table_load");// 读取表
                String table_new = tableOneMap.get("table_new"); // 存储表
                String way = tableOneMap.get("way");
                String inc_field = tableOneMap.get("inc_field");

                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + table_load + " 开始");
                String masterTableName = MasterDatabaseName + "." + table_load;

                for (int years = 2011; years <2026 ; years++) {

                    StringBuffer stringBufferEnd = new StringBuffer();
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-01-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-02-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-02-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-03-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-03-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-04-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-04-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-05-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-05-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-06-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-06-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-07-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-07-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-08-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-08-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-09-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-09-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-10-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-10-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-11-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-11-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-12-01', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-12-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+(years+1)+"-01-01', 'YYYY-MM-DD');");

                    String fileds = "C_APP_NO,\n" +
                            "  C_APP_TYP,\n" +
                            "  C_PLY_NO,\n" +
                            "  N_EDR_PRJ_NO,\n" +
                            "  C_EDR_NO,\n" +
                            "  C_REL_PLY_NO,\n" +
                            "  C_PROD_NO,\n" +
                            "  C_DPT_CDE,\n" +
                            "  C_BSNS_TYP,\n" +
                            "  C_BSNS_SUBTYP,\n" +
                            "  C_BRKR_CDE,\n" +
                            "  C_AGT_AGR_NO,\n" +
                            "  N_SUB_CO_NO,\n" +
                            "  C_OC_PLY_NO,\n" +
                            "  N_DISC_RATE,\n" +
                            "  N_RATE,\n" +
                            "  N_COMM_RATE,\n" +
                            "  C_RENEW_MRK,\n" +
                            "  C_ORIG_PLY_NO,\n" +
                            "  C_ORIG_INSURER,\n" +
                            "  C_AMT_CUR,\n" +
                            "  N_AMT,\n" +
                            "  N_AMT_RMB_EXCH,\n" +
                            "  C_PRM_CUR,\n" +
                            "  N_CALC_PRM,\n" +
                            "  N_PRM,\n" +
                            "  N_PRM_RMB_EXCH,\n" +
                            "  N_INDEM_LMT,\n" +
                            "  C_RATIO_TYP,\n" +
                            "  N_RATIO_COEF,\n" +
                            "  N_SAVING_AMT,\n" +
                            "  C_PRM_STS,\n" +
                            "  C_PLY_STS,\n" +
                            "  T_TERMN_TM,\n" +
                            "  C_INWD_MRK,\n" +
                            "  C_CI_MRK,\n" +
                            "  C_CI_TYP,\n" +
                            "  N_CI_JNT_AMT,\n" +
                            "  N_CI_JNT_PRM,\n" +
                            "  C_LONG_TERM_MRK,\n" +
                            "  T_APP_TM,\n" +
                            "  C_OPR_TYP,\n" +
                            "  C_PRN_NO,\n" +
                            "  T_INSRNC_BGN_TM,\n" +
                            "  T_INSRNC_END_TM,\n" +
                            "  C_TM_SYS_CDE,\n" +
                            "  C_UNFIX_SPC,\n" +
                            "  C_GRP_MRK,\n" +
                            "  C_MULT_INSRNT_MRK,\n" +
                            "  C_LISTORCOL_MRK,\n" +
                            "  C_MASTER_MRK,\n" +
                            "  C_BID_MRK,\n" +
                            "  C_PKG_MRK,\n" +
                            "  C_PKG_NO,\n" +
                            "  N_PRM_DISC,\n" +
                            "  C_REG_MRK,\n" +
                            "  C_DEC_MRK,\n" +
                            "  C_JURI_CDE,\n" +
                            "  C_AGRI_MRK,\n" +
                            "  C_FOREIGN_MRK,\n" +
                            "  C_IMPOREXP_MRK,\n" +
                            "  C_MANUAL_MRK,\n" +
                            "  C_INST_MRK,\n" +
                            "  C_VIP_MRK,\n" +
                            "  C_OPEN_COVER_NO,\n" +
                            "  C_DISPT_STTL_CDE,\n" +
                            "  C_DISPT_STTL_ORG,\n" +
                            "  C_CHK_CDE,\n" +
                            "  T_ISSUE_TM,\n" +
                            "  T_UDR_TM,\n" +
                            "  C_UDR_DPT_CDE,\n" +
                            "  C_UDR_MRK,\n" +
                            "  C_RI_FAC_MRK,\n" +
                            "  C_RI_CHK_CDE,\n" +
                            "  C_RI_MRK,\n" +
                            "  T_NEXT_EDR_BGN_TM,\n" +
                            "  T_NEXT_EDR_END_TM,\n" +
                            "  T_NEXT_EDR_UDR_TM,\n" +
                            "  C_REVERT_MRK,\n" +
                            "  C_REMARK,\n" +
                            "  T_EDR_APP_TM,\n" +
                            "  T_EDR_BGN_TM,\n" +
                            "  T_EDR_END_TM,\n" +
                            "  C_EDR_MRK,\n" +
                            "  C_EDR_TYPE,\n" +
                            "  C_EDR_RSN_BUNDLE_CDE,\n" +
                            "  N_BEF_EDR_PRJ_NO,\n" +
                            "  N_BEF_EDR_AMT,\n" +
                            "  N_BEF_EDR_PRM,\n" +
                            "  C_LATEST_MRK,\n" +
                            "  N_AMT_VAR,\n" +
                            "  N_CALC_PRM_VAR,\n" +
                            "  N_PRM_VAR,\n" +
                            "  N_INDEM_LMT_VAR,\n" +
                            "  C_APP_PRSN_CDE,\n" +
                            "  C_APP_PRSN_NME,\n" +
                            "  C_EDR_CTNT,\n" +
                            "  C_GRANT_DPT_CDE,\n" +
                            "  C_VIP_CUS,\n" +
                            "  N_MAX_FEE_PROP,\n" +
                            "  C_FIN_TYP,\n" +
                            "  N_ORIG_TIMES,\n" +
                            "  C_DPT_ATTR,\n" +
                            "  C_SALEGRP_CDE,\n" +
                            "  C_SLS_TEL,\n" +
                            "  C_SLS_NME,\n" +
                            "  C_FRZ_MRK,\n" +
                            "  C_FEE_CAL_TYP,\n" +
                            "  C_RATE_NO,\n" +
                            "  C_COMMON_FLAG,\n" +
                            "  C_SAVE_MRK,\n" +
                            "  N_BEF_EDR_SAVING,\n" +
                            "  N_SAVING_VAR,\n" +
                            "  C_TRANS_MRK,\n" +
                            "  T_TRANS_TM,\n" +
                            "  C_IMMEFF_MRK,\n" +
                            "  C_DATA_SRC,\n" +
                            "  C_QUOTE_NO,\n" +
                            "  N_BASE_PRM,\n" +
                            "  N_ALL_PRM,\n" +
                            "  N_IRR_RATIO,\n" +
                            "  C_QUOTA_MRK,\n" +
                            "  C_LARGE_BUSINESS,\n" +
                            "  C_SUS_BUSINESS,\n" +
                            "  C_CHA_TYPE,\n" +
                            "  C_CHA_SUBTYPE,\n" +
                            "  C_SUR_FORMULA,\n" +
                            "  C_NOENDCLM_MRK,\n" +
                            "  N_TAX_AMT,\n" +
                            "  T_REPSTOPEXT_BGN_TM,\n" +
                            "  T_REPSTOPEXT_END_TM,\n" +
                            "  C_REPSTOPEXT_RLE_APP_NO,\n" +
                            "  T_REPSTOPEXT_LAST_END_TM,\n" +
                            "  T_SRC_INSRNC_BGN_TM,\n" +
                            "  T_SRC_INSRNC_END_TM,\n" +
                            "  C_REPSTOPEXT_STATUS,\n" +
                            "  C_REPSTOPEXT_SRC_APP_NO,\n" +
                            "  C_TENDER_NO,\n" +
                            "  C_PREFERENTIAL,\n" +
                            "  N_COMMISSION_RATE_UPPER,\n" +
                            "  C_AREA_FLAG,\n" +
                            "  C_CERTF_NO,\n" +
                            "  C_TRD_CDE,\n" +
                            "  N_CI_OWN_AMT,\n" +
                            "  N_CI_OWN_PRM,\n" +
                            "  C_NEEDFEE_FLAG,\n" +
                            "  C_CANCLFEE_FLG,\n" +
                            "  C_CANCLFEERSN_CDE,\n" +
                            "  C_CI_INP_TYP,\n" +
                            "  C_CI_PRI_TYP,\n" +
                            "  T_RUN_BGN_TM,\n" +
                            "  T_RUN_END_TM,\n" +
                            "  C_PAYMENT_MRK,\n" +
                            "  C_DANZHENG_TYP,\n" +
                            "  C_UNFIX_SPC_CHANGE,\n" +
                            "  C_UNFIX_SPC_HIDDEN,\n" +
                            "  N_SURR_RATE,\n" +
                            "  C_MONITOR_ID,\n" +
                            "  C_QUICK_FLAG,\n" +
                            "  C_ISLOG_BACK,\n" +
                            "  C_BRK_SLS_NAME,\n" +
                            "  C_UNDR_OPN,\n" +
                            "  C_UNFIX_SPC_ILOG,\n" +
                            "  N_FUND_RATE,\n" +
                            "  N_FUND_AMOUNT,\n" +
                            "  C_CARD_NO,\n" +
                            "  C_BILL_NO,\n" +
                            "  C_CARD_PLAN_NO,\n" +
                            "  C_CARD_PLAN_NME,\n" +
                            "  C_CARD_BSNS_TYP,\n" +
                            "  C_CARD_MRK,\n" +
                            "  C_INTRO_DPTCDE,\n" +
                            "  C_PRJ_CTG_TYP,\n" +
                            "  C_INTER_FAC_TYP,\n" +
                            "  N_FAC_MIN,\n" +
                            "  N_FAC_MAX,\n" +
                            "  N_HOPE_PRM,\n" +
                            "  N_HOPE_RATE,\n" +
                            "  N_FIT_RATE,\n" +
                            "  N_FIT_PRM,\n" +
                            "  C_BATCH_NO,\n" +
                            "  C_BATCH_SEQ_NO,\n" +
                            "  C_EDR_RATIO_TYP,\n" +
                            "  N_PAY_NUM,\n" +
                            "  C_SLS_DPTCDE,\n" +
                            "  N_REFUND_PRM,\n" +
                            "  C_OPR_CDE,\n" +
                            "  C_UDR_CDE,\n" +
                            "  C_BRK_SLS_CDE,\n" +
                            "  C_SLS_ID,\n" +
                            "  C_SLS_CDE,\n" +
                            "  C_APPROVE_CDE,\n" +
                            "  C_INTRO_SALECDE,\n" +
                            "  C_CRT_CDE,\n" +
                            "  C_UPD_CDE,\n" +
                            "  C_AGREE_NO,\n" +
                            "  C_AGREE_TYP,\n" +
                            "  C_RISK_LVL_CDE,\n" +
                            "  C_IS_MONEY_CANEL,\n" +
                            "  C_ECARGO_EDR_RSNTXT,\n" +
                            "  C_CHANNEL_CDE,\n" +
                            "  C_CHANNEL_COM_CDE,\n" +
                            "  C_PRM_SRC,\n" +
                            "  C_REPSTOPEXT_BTZQ_STATUS,\n" +
                            "  C_RECEI_TITLE_CDE as C_RECEIPT_TITLE_CDE,\n" +
                            "  C_RECEI_TITLE_NME as C_RECEIPT_TITLE_NME,\n" +
                            "  N_SALEFEE_RATE,\n" +
                            "  C_SALEFEE_RATE_FLAG,\n" +
                            "  C_SUBPROD_NO,\n" +
                            "  C_STOP_TRAVEL_REASON,\n" +
                            "  C_VCH_DPT_CDE,\n" +
                            "  C_DANGER_LEVEL,\n" +
                            "  N_AP_PREMIUM_BEFORE_FITTING,\n" +
                            "  N_AP_PREMIUM_BEFORE_FITTING2,\n" +
                            "  N_AP_PREMIUM_FITTING_RATE2,\n" +
                            "  N_AP_PREMIUM2,\n" +
                            "  N_FITTING_RATE2,\n" +
                            "  N_FITTING_PRM2,\n" +
                            "  N_COMPENSATION_RATE,\n" +
                            "  N_TOUCH_NET_FLAG,\n" +
                            "  C_BRKR_DPTCDE,\n" +
                            "  C_CBU_CODE,\n" +
                            "  C_APP_REL_TYP,\n" +
                            "  C_PLY_REL_NO,\n" +
                            "  C_APP_REL_NO,\n" +
                            "  C_BUN_TRACK_INF,\n" +
                            "  C_RENEW_TYP,\n" +
                            "  T_LAST_YEAR_END_DATE,\n" +
                            "  C_SALE_JZJY_TYP,\n" +
                            "  C_REPAIR_SHOP_CDE,\n" +
                            "  C_JI_NO,\n" +
                            "  N_JI_JNT_AMT,\n" +
                            "  N_JI_JNT_PRM,\n" +
                            "  C_JI_AGT_NO,\n" +
                            "  C_CI_OPR_REL,\n" +
                            "  C_SPECIALMARKER,\n" +
                            "  C_APPOINT_AREA_CODE,\n" +
                            "  C_ISFULL_ENDOR,\n" +
                            "  C_COUNTY_NAME,\n" +
                            "  C_USAGE_CDE,\n" +
                            "  C_QTE_NO,\n" +
                            "  N_POINTS_AND_AMOUNT,\n" +
                            "  N_REMAINING_POINTS_AND_AMOUNT,\n" +
                            "  N_DEDUCT_POINTS_AND_AMOUNT,\n" +
                            "  N_NOTAX_PRM,\n" +
                            "  N_ADDED_TAX,\n" +
                            "  N_NOTAX_PRM_VAR,\n" +
                            "  N_ADDED_TAX_VAR,\n" +
                            "  T_CANCEL_REASON_DATE,\n" +
                            "  C_ELECTRONIC_POLICY_FLAG,\n" +
                            "  C_PRINTING_NUMBER,\n" +
                            "  C_CALL_BACK,\n" +
                            "  C_UNION_MRK,\n" +
                            "  C_TAX_TYP,\n" +
                            "  C_COLL_TYP,\n" +
                            "  N_NET_PRM,\n" +
                            "  N_NET_PRM_VAR,\n" +
                            "  C_CVRG_TYP as C_TERM_TYP,\n" +
                            "  c_resv_txt_6 as N_GROSS_PROFIT,\n" +
                            "  c_resv_txt_7 as N_AUDIT_FEE,\n" +
                            "  C_RESV_TXT_4 as C_CI_AGT_NO,\n" +
                            "  C_RESV_TXT_8 as T_DEPARTURE_DATE,\n" +
                            "  C_PRJ_CTG_MIDTYP as C_PRJ_CTG_MID_TYP,\n" +
                            "  C_PRJ_CTG_SUBTYP as C_PRJ_CTG_SUB_TYP,\n" +
                            "  N_APP_REMIUM_FITTING_RATE as N_APP_PREMIUM_FITTING_RATE,\n" +
                            "  N_APP_REMIUMA_0 as N_APP_PREMIUMA_0,\n" +
                            "  N_APP_REMIUMA_1 as N_APP_PREMIUMA_1,\n" +
                            "  N_APP_REMIUMA_2 as N_APP_PREMIUMA_2,\n" +
                            "  N_APP_REMIUMC_0 as N_APP_PREMIUMC_0,\n" +
                            "  N_APP_REMIUMC_1 as N_APP_PREMIUMC_1,\n" +
                            "  N_APP_REMIUMC_2 as N_APP_PREMIUMC_2,\n" +
                            "  N_APP_REMIUMB_0 as N_APP_PREMIUMB_0,\n" +
                            "  N_APP_REMIUMB_1 as N_APP_PREMIUMB_1,\n" +
                            "  N_APP_REMIUMB_2 as N_APP_PREMIUMB_2,\n" +
                            "  C_UNFIX_SPC AS C_SPECIAL_CONTENT";

                    for (String sql : stringBufferEnd.toString().split(";")) {

                        System.out.println("读取数据");
                        System.out.println(sql);
                        List<Map<String, Object>> dataList = masterOracleMapper.selectData2(sql,fileds);
                        System.out.println("数据存储量：" + dataList.size());

                        if (dataList.size()>0) {
                            for (String table_new_one : table_new.split(",")) {

                                OracleTable oracleTable = null;
                                if (table_new_one.equals("WEB_MIGRATE_APPNO")) {
                                    oracleTable = selectOracle(MasterDatabaseName,table_new_one);
                                }
                                else {
                                    oracleTable = selectOracle(SlaveDatabaseName,table_new_one+years);
                                }

                                if (oracleTable.getFieldList().size()<1) {
                                    oracleTable.setExMessage("此数据表无字段，无法迁移！！");
                                    extable.add(oracleTable);
                                    continue;
                                }
                                oracleTable.setDataList(dataList);
                                if (dataList.size()>0) {

                                    String id = tableOneMap.get(table_new_one + "_id");
                                    // 处理主键问题
                                    String[] idSpl = id.split(",");
                                    for (String string : idSpl) {
                                        oracleTable.getFieldKeyList().add(string);
                                    }

                                    System.out.println("组合存储数据");
                                    List<List<Map<String, Object>>> lists = splitList(oracleTable.getDataList());
                                    int a = 1;
                                    for (List<Map<String, Object>> list : lists) {
                                        System.out.println("删除组合批次："+lists.size()+"/"+a+++",当前数据量："+list.size());
                                        System.out.println("组合主键的删除语句");
                                        if (table_new_one.equals("WEB_MIGRATE_APPNO")) {
                                            String creatIdOracle = creatIdOracle(oracleTable.getDataBaseName(), oracleTable.getTableName(), oracleTable.getFieldKeyList(), list);
                                            try {
                                                System.out.println("执行删除");
                                                masterOracleMapper.creatOracle(creatIdOracle);
                                            }catch (Exception e){
                                                System.out.println("删除方法一失败！！！");
                                                oracleTable.setExMessage("数据删除失败："+creatIdOracle);
                                                extable.add(oracleTable);
                                                continue;
                                            }
                                        }
                                        else {
                                            for(int b = 2011;b <= years; b++){
                                                System.out.println("年份："+b);
                                                String creatIdOracle = creatIdOracle2(oracleTable.getDataBaseName(), table_new_one+b, oracleTable.getFieldKeyList(), list);
                                                try {
                                                    System.out.println("执行删除");
                                                    slaveOracleMapper.creatOracle(creatIdOracle);
                                                }catch (Exception e){
                                                    System.out.println("删除方法一失败！！！");
                                                    oracleTable.setExMessage("数据删除失败："+creatIdOracle);
                                                    extable.add(oracleTable);
                                                    continue;
                                                }
                                            }
                                        }
                                    }


                                    a = 1;
                                    for (List<Map<String, Object>> list : lists) {
                                        System.out.println("存储组合批次："+lists.size()+"/"+a+++",当前数据量："+list.size());
                                        if (table_new_one.equals("WEB_MIGRATE_APPNO")) {
                                            oracleTable.setTableName("WEB_MIGRATE_APPNO");
                                        }
                                        String creatInsert = creatInsertOracle3(oracleTable.getDataBaseName(), oracleTable.getTableName(), oracleTable.getFieldList(), list);
                                        // 执行存储数据
                                        try {
                                            System.out.println("执行存储");
                                            if (table_new_one.equals("WEB_MIGRATE_APPNO")) {
                                                masterOracleMapper.creatOracle(creatInsert);
                                            }
                                            else {
                                                slaveOracleMapper.creatOracle(creatInsert);
                                            }
                                        }catch (Exception e){
                                            System.out.println("存储方法一失败！！！");
                                            oracleTable.setExMessage("数据存储失败："+creatInsert);
                                            extable.add(oracleTable);
                                        }
                                    }

                                    System.out.println("存储完成");
                                }

                            }
                        }

                    }
                }

                System.out.println("数据表名：" + table_load + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());

            if (extable.size()>0) {
                System.out.println("以下失败表名");
                for (OracleTable s : extable) {
                    System.out.println(s.getTableName());
                }
            }

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }
    }

    public void tableTONewTableYears(List<Map<String,String>> OracleTableList){
        if (OracleTableList.size()>0) {
            List<OracleTable> extable = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;
            for (Map<String,String> tableOneMap : OracleTableList) {

                String table_load = tableOneMap.get("table_load");// 读取表
                String table_new = tableOneMap.get("table_new"); // 存储表
                String way = tableOneMap.get("way");
                String inc_field = tableOneMap.get("inc_field");
                String filed = tableOneMap.get("filed");

                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + table_load + " 开始");
                String masterTableName = MasterDatabaseName + "." + table_load;

                for (int years = 2012; years <2026 ; years++) {
                    StringBuffer stringBufferEnd = new StringBuffer();
                    if (years!=2010) {
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-01-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-01-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-01-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-02-01', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-02-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-02-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-02-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-03-01', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-03-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-03-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-03-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-04-01', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-04-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-04-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-04-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-05-01', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-05-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-05-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-05-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-06-01', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-06-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-06-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-06-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-07-01', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-07-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-07-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-07-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-08-01', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-08-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-08-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-08-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-09-01', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-09-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-09-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-09-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-10-01', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-10-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-10-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-10-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-11-01', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-11-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-11-15', 'YYYY-MM-DD');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-11-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-12-01', 'YYYY-MM-DD');");
                    }
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-12-01', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+years+"-12-15', 'YYYY-MM-DD');");
                    stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE('"+years+"-12-15', 'YYYY-MM-DD') AND T_UPD_TM<TO_DATE('"+(years+1)+"-01-01', 'YYYY-MM-DD');");

                    String fileds = "";
                    if (filed==null || filed.equals("null")) {
                        OracleTable oracleTableLOad = selectOracle(MasterDatabaseName, table_load);
                        if (oracleTableLOad.getFieldList().size()>0) {
                            for (OracleField oracleField : oracleTableLOad.getFieldList()) {
                                fileds = fileds + oracleField.getCOLUMN_NAME() + ",";
                            }
                            fileds=fileds.substring(0,fileds.length()-1);
                        }
                    }
                    else {
                        fileds = filed;
                    }

                    for (String sql : stringBufferEnd.toString().split(";")) {

                        System.out.println("读取数据");
                        System.out.println(sql);
                        List<Map<String, Object>> dataList = masterOracleMapper.selectData2(sql,fileds);
                        System.out.println("数据存储量：" + dataList.size());

                        if (dataList.size()>0) {
                            for (String table_new_one : table_new.split(",")) {

                                OracleTable oracleTable = null;
                                if (table_new_one.equals("WEB_MIGRATE_APPNO")) {
                                    oracleTable = selectOracle(MasterDatabaseName,table_new_one);
                                }
                                else {
                                    oracleTable = selectOracleSlave(SlaveDatabaseName,table_new_one+years);
                                }

                                if (oracleTable.getFieldList().size()<1) {
                                    oracleTable.setExMessage("此数据表无字段，无法迁移！！");
                                    extable.add(oracleTable);
                                    continue;
                                }
                                oracleTable.setDataList(dataList);
                                if (dataList.size()>0) {

                                    String id = tableOneMap.get(table_new_one + "_id");
                                    // 处理主键问题
                                    String[] idSpl = id.split(",");
                                    for (String string : idSpl) {
                                        oracleTable.getFieldKeyList().add(string);
                                    }

                                    System.out.println("组合存储数据");
                                    List<List<Map<String, Object>>> lists = splitList(oracleTable.getDataList());
                                    int a = 1;
                                    for (List<Map<String, Object>> list : lists) {
                                        System.out.println("删除组合批次："+lists.size()+"/"+a+++",当前数据量："+list.size());
                                        System.out.println("组合主键的删除语句");
                                        if (table_new_one.equals("WEB_MIGRATE_APPNO")) {
                                            String creatIdOracle = creatIdOracle(oracleTable.getDataBaseName(), oracleTable.getTableName(), oracleTable.getFieldKeyList(), list);
                                            try {
                                                System.out.println("执行删除");
                                                masterOracleMapper.creatOracle(creatIdOracle);
                                            }catch (Exception e){
                                                System.out.println("删除方法一失败！！！");
                                                oracleTable.setExMessage("数据删除失败："+creatIdOracle);
                                                extable.add(oracleTable);
                                                continue;
                                            }
                                        }
                                        else {
                                            for(int b = 2011;b <= years; b++){
                                                System.out.println("年份："+b);
                                                String creatIdOracle = creatIdOracle2(oracleTable.getDataBaseName(), table_new_one+b, oracleTable.getFieldKeyList(), list);
                                                try {
                                                    System.out.println("执行删除");
                                                    slaveOracleMapper.creatOracle(creatIdOracle);
                                                }catch (Exception e){
                                                    System.out.println("删除方法一失败！！！");
                                                    oracleTable.setExMessage("数据删除失败："+creatIdOracle);
                                                    extable.add(oracleTable);
                                                    continue;
                                                }
                                            }
                                        }
                                    }


                                    a = 1;
                                    for (List<Map<String, Object>> list : lists) {
                                        System.out.println("存储组合批次："+lists.size()+"/"+a+++",当前数据量："+list.size());
                                        if (table_new_one.equals("WEB_MIGRATE_APPNO")) {
                                            oracleTable.setTableName("WEB_MIGRATE_APPNO");
                                        }
                                        String creatInsert = creatInsertOracle3(oracleTable.getDataBaseName(), oracleTable.getTableName(), oracleTable.getFieldList(), list);
                                        // 执行存储数据
                                        try {
                                            System.out.println("执行存储");
                                            if (table_new_one.equals("WEB_MIGRATE_APPNO")) {
                                                masterOracleMapper.creatOracle(creatInsert);
                                            }
                                            else {
                                                slaveOracleMapper.creatOracle(creatInsert);
                                            }
                                        }catch (Exception e){
                                            System.out.println("存储方法一失败！！！");
                                            oracleTable.setExMessage("数据存储失败："+creatInsert);
                                            extable.add(oracleTable);
                                        }
                                    }

                                    System.out.println("存储完成");
                                }

                            }
                        }

                    }
                }

                System.out.println("数据表名：" + table_load + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());

            if (extable.size()>0) {
                System.out.println("以下失败表名");
                for (OracleTable s : extable) {
                    System.out.println(s.getTableName());
                }
            }

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }
    }

    public void tableTONewTableYearsCG(List<Map<String,String>> OracleTableList){
        if (OracleTableList.size()>0) {
            List<OracleTable> extable = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;
            for (Map<String,String> tableOneMap : OracleTableList) {

                String table_load = tableOneMap.get("table_load");// 读取表
                String table_new = tableOneMap.get("table_new"); // 存储表
                String way = tableOneMap.get("way");
                String inc_field = tableOneMap.get("inc_field");
                String filed = tableOneMap.get("filed");
                String filed_n = tableOneMap.get("filed_n");
                String BTS = tableOneMap.get("BTS");
                String lowerCase = tableOneMap.get("lowerCase");
                String year_cs = tableOneMap.get("year_cs");
                String where_sql = tableOneMap.get("where_sql");

                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + table_load + " 开始");
                String masterTableName = MasterDatabaseName + "." + table_load;

                if (way.equals("all")) {

                    String sql = "TRUNCATE TABLE PCISV6_2.\""+table_new+"\"";
                    System.out.println(sql);
                    slaveOracleMapper.creatOracle(sql);

                    String fileds = "";
                    if (filed==null || filed.equals("null")) {
                        OracleTable oracleTableLOad = selectOracle(MasterDatabaseName, table_load);
                        if (oracleTableLOad.getFieldList().size()>0) {
                            for (OracleField oracleField : oracleTableLOad.getFieldList()) {
                                fileds = fileds + oracleField.getCOLUMN_NAME() + ",";
                            }
                            fileds=fileds.substring(0,fileds.length()-1);
                        }
                    }
                    else {
                        fileds = filed;
                    }

                    if (filed_n==null || filed_n.equals("null")) {
                        filed_n = fileds;
                        if (lowerCase==null) {
                            filed_n = filed_n.toLowerCase();
                        }
                    }
                    else {
                        if (lowerCase==null) {
                            filed_n = filed_n.toLowerCase();
                        }
                    }

                    String newFile = "";
                    for (String string : filed_n.split(",")) {
                        string= string.replaceAll(" ","");
                        newFile = newFile + "\""+string+"\",";
                    }
                    newFile = newFile.substring(0,newFile.length()-1);

                    sql = "BEGIN\n" +
                            "  MIGRATE_TABLE_NOYEAR('PCISV6_2."+table_new+"','"+newFile+"','"+fileds+"','"+masterTableName+"');\n" +
                            "END;";
                    System.out.println(sql);
                    try {
                        String creatOracle = masterOracleMapper.creatOracle(sql);
                    }catch (Exception e){
                        e.printStackTrace();
                        continue;
                    }

                }
                else{
                    boolean a = false;
                    for (int years = 2021; years <2026 ; years++) {
                        List<String> stringBufferEnd  = new ArrayList<>();

                        if (BTS.equals("B")) {
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-01-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-01-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-01-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-02-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-02-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-03-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-03-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-04-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-04-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-05-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-05-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-06-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-06-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-07-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-07-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-08-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-08-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-09-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-09-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-10-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-10-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-11-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-11-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-12-15'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-12-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+(years+1)+"-01-01'', ''YYYY-MM-DD'')");
                        }

                        else if (BTS.equals("S")) {
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-01-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-01-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-01-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-01-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-01-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-02-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-02-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-02-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-02-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-03-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-03-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-03-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-03-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-04-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-04-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-04-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-04-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-05-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-05-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-05-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-05-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-06-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-06-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-06-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-06-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-07-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-07-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-07-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-07-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-08-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-08-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-08-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-08-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-09-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-09-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-09-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-09-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-10-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-10-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-10-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-10-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-11-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-11-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-11-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-11-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-12-11'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-12-11'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+years+"-12-21'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+"=TO_DATE(''"+years+"-12-21'', ''YYYY-MM-DD'') AND "+inc_field+"TO_DATE(''"+(years+1)+"-01-01'', ''YYYY-MM-DD'')");
                        }

                        else if (BTS.equals("M")) {
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-01-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'')");
                            stringBufferEnd.add(" "+inc_field+">=TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+(years+1)+"-01-01'', ''YYYY-MM-DD'')");

                        }

                        else if (BTS.equals("D")) {
                            for (int mon = 1; mon <= 12; mon++) {
                                // 处理月份补零
                                String monthStr = mon < 10 ? "0" + mon : String.valueOf(mon);

                                // 获取当前月的最大天数
                                int maxDay = getMaxDayOfMonth(years, mon);

                                // 生成每日区间条件（1号到maxDay-1号）
                                for (int day = 1; day < maxDay; day++) {
                                    String startDay = day < 10 ? "0" + day : String.valueOf(day);
                                    String endDay = (day + 1) < 10 ? "0" + (day + 1) : String.valueOf(day + 1);

                                    stringBufferEnd.add(" "+inc_field+">=TO_DATE(''" + years + "-" + monthStr + "-" + startDay + "'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''" + years + "-" + monthStr + "-" + endDay + "'', ''YYYY-MM-DD'')");
                                }

                                // 处理跨月最后一天（当前月maxDay到下月1号）
                                String nextMonthStr;
                                String nextYear;
                                if (mon == 12) {
                                    nextYear = String.valueOf(years + 1);
                                    nextMonthStr = "01"; // 12月之后是次年1月，补零处理
                                } else {
                                    nextYear = String.valueOf(years);
                                    nextMonthStr = (mon + 1) < 10 ? "0" + (mon + 1) : String.valueOf(mon + 1);
                                }

                                stringBufferEnd.add(" "+inc_field+">=TO_DATE(''" + years + "-" + monthStr + "-" + maxDay + "'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''" + nextYear + "-" + nextMonthStr + "-01'', ''YYYY-MM-DD'')");
                            }
                        }

                        else if (BTS.equals("H")) {
                            for (int mon = 1; mon <= 12; mon++) {
                                // 处理月份补零
                                String monthStr = mon < 10 ? "0" + mon : String.valueOf(mon);

                                // 获取当前月的最大天数
                                int maxDay = getMaxDayOfMonth(years, mon);

                                // 生成每日的小时区间条件
                                for (int day = 1; day <= maxDay; day++) {
                                    String dayStr = day < 10 ? "0" + day : String.valueOf(day);

                                    // 当月每日的0-23小时
                                    for (int hour = 0; hour < 23; hour++) {
                                        String startHourStr = hour < 10 ? "0" + hour : String.valueOf(hour);
                                        String endHourStr = (hour + 1) < 10 ? "0" + (hour + 1) : String.valueOf(hour + 1);

                                        stringBufferEnd.add(" " + inc_field + ">=TO_DATE(''" + years + "-" + monthStr + "-" + dayStr + " " + startHourStr + ":00:00'', ''YYYY-MM-DD HH24:MI:SS'') AND "
                                                + inc_field + "<TO_DATE(''" + years + "-" + monthStr + "-" + dayStr + " " + endHourStr + ":00:00'', ''YYYY-MM-DD HH24:MI:SS'')");
                                    }

                                    // 处理每日的23-24时(即次日0点)
                                    String nextDayStr;
                                    String nextMonth;
                                    String nextYear;

                                    // 判断是否需要跨月
                                    if (day == maxDay) {
                                        // 月末最后一天，需要处理跨月
                                        if (mon == 12) {
                                            // 年末最后一天，需要跨年
                                            nextYear = String.valueOf(years + 1);
                                            nextMonth = "01";
                                        } else {
                                            nextYear = String.valueOf(years);
                                            nextMonth = (mon + 1) < 10 ? "0" + (mon + 1) : String.valueOf(mon + 1);
                                        }
                                        nextDayStr = "01"; // 下月第一天
                                    } else {
                                        // 非月末，正常处理下一天
                                        nextYear = String.valueOf(years);
                                        nextMonth = monthStr;
                                        nextDayStr = (day + 1) < 10 ? "0" + (day + 1) : String.valueOf(day + 1);
                                    }

                                    stringBufferEnd.add(" " + inc_field + ">=TO_DATE(''" + years + "-" + monthStr + "-" + dayStr + " 23:00:00'', ''YYYY-MM-DD HH24:MI:SS'') AND "
                                            + inc_field + "<TO_DATE(''" + nextYear + "-" + nextMonth + "-" + nextDayStr + " 00:00:00'', ''YYYY-MM-DD HH24:MI:SS'')");
                                }
                            }
                        }

                        String fileds = "";
                        if (filed==null || filed.equals("null")) {
                            OracleTable oracleTableLOad = selectOracle(MasterDatabaseName, table_load);
                            if (oracleTableLOad.getFieldList().size()>0) {
                                for (OracleField oracleField : oracleTableLOad.getFieldList()) {
                                    fileds = fileds + oracleField.getCOLUMN_NAME() + ",";
                                }
                                fileds=fileds.substring(0,fileds.length()-1);
                            }
                        }
                        else {
                            fileds = filed;
                        }

                        if (filed_n==null || filed_n.equals("null")) {
                            filed_n = fileds;
                            if (lowerCase==null) {
                                filed_n = filed_n.toLowerCase();
                            }
                        }
                        else {
                            if (lowerCase==null) {
                                filed_n = filed_n.toLowerCase();
                            }
                        }

                        List<String> sqlAll = new ArrayList<>();
                        for (String sql : stringBufferEnd) {

                            if (table_new.equals("WEB_CLM_RPT")
                                    ||table_new.equals("WEB_CLM_ACCDNT")
                                    ||table_new.equals("WEB_CLM_CASE_STATE")) {
                                sql = masterTableName + " WHERE" + sql + " AND C_CLM_NO IN (SELECT C_CLM_NO FROM WEB_CLM_MAIN_END)";
                            }
                            else if(where_sql!=null){
                                sql = where_sql.replace("${WHERE}",sql);
                            }
                            else {
                                sql = masterTableName + " WHERE" + sql;
                            }


//                            if (a) {
//                                sqlAll.add(sql);
//                            }
//                            if (sql.contains("2011-12-02")) {
//                                a = true;
//                            }
                            sqlAll.add(sql);

                        }

                        if (sqlAll.size()>0) {
                            BigDecimal one = new BigDecimal(sqlAll.size());
                            BigDecimal two = new BigDecimal(5);
                            BigDecimal divide = one.divide(two, RoundingMode.HALF_UP);
                            divide = divide.add(new BigDecimal(1));
                            final int[] b = {0};
                            for (Integer i = 1; i <= Integer.valueOf(String.valueOf(divide.toString())); i++) {
                                CountDownLatch latch = new CountDownLatch(5);
                                try {
                                    String finalFileds = fileds;
                                    String finalFiled_n = filed_n;
                                    int finalYears = years;
                                    Thread thread = new Thread(()->{
                                        try {
                                            XCCG(finalFileds,sqlAll.get(b[0]),table_new, finalFiled_n, finalYears,year_cs);
                                        }catch (Exception e){
                                            System.out.println("集合没有多余的执行");
                                            e.printStackTrace();
                                        }
                                        latch.countDown();
                                    });
                                    thread.start();
                                    Thread.sleep(2000);
                                    b[0] = b[0] + 1;

                                    Thread thread2 = new Thread(()->{
                                        try {
                                            XCCG(finalFileds,sqlAll.get(b[0]),table_new, finalFiled_n, finalYears,year_cs);
                                        }catch (Exception e){
                                            System.out.println("集合没有多余的执行");
                                            e.printStackTrace();
                                        }
                                        latch.countDown();
                                    });
                                    thread2.start();
                                    Thread.sleep(2000);
                                    b[0] = b[0] + 1;

                                    Thread thread3 = new Thread(()->{
                                        try {
                                            XCCG(finalFileds,sqlAll.get(b[0]),table_new, finalFiled_n, finalYears,year_cs);
                                        }catch (Exception e){
                                            System.out.println("集合没有多余的执行");
                                            e.printStackTrace();
                                        }
                                        latch.countDown();
                                    });
                                    thread3.start();
                                    Thread.sleep(2000);
                                    b[0] = b[0] + 1;

                                    Thread thread4 = new Thread(()->{
                                        try {
                                            XCCG(finalFileds,sqlAll.get(b[0]),table_new, finalFiled_n, finalYears,year_cs);
                                        }catch (Exception e){
                                            System.out.println("集合没有多余的执行");
                                            e.printStackTrace();
                                        }
                                        latch.countDown();
                                    });
                                    thread4.start();
                                    Thread.sleep(2000);
                                    b[0] = b[0] + 1;

                                    Thread thread5 = new Thread(()->{
                                        try {
                                            XCCG(finalFileds,sqlAll.get(b[0]),table_new, finalFiled_n, finalYears,year_cs);
                                        }catch (Exception e){
                                            System.out.println("集合没有多余的执行");
                                            e.printStackTrace();
                                        }
                                        latch.countDown();
                                    });
                                    thread5.start();
                                    Thread.sleep(2000);
                                    b[0] = b[0] + 1;

                                    System.out.println("等待开始");
                                    try {
                                        latch.await();
                                    } catch (InterruptedException e) {
                                        e.printStackTrace();
                                    }
                                    System.out.println("等待结束");

                                }catch (Exception e){
                                    e.printStackTrace();
                                }
                            }
                        }

                        System.out.println("执行存过结束");
                    }
                }

                System.out.println("数据表名：" + table_load + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());

            if (extable.size()>0) {
                System.out.println("以下失败表名");
                for (OracleTable s : extable) {
                    System.out.println(s.getTableName());
                }
            }

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }
    }

    public boolean XCCG(String fileds,String sql,String table_new,String filed_n,int years,String year_cs){
        System.out.println("SELECT "+fileds + " FROM " + sql);
        for (String table_new_one : table_new.split(",")) {
            System.out.println("执行存过开始");
            String newFile = "";
            for (String string : filed_n.split(",")) {
                string= string.replaceAll(" ","");
                newFile = newFile + "\""+string+"\",";
            }
            newFile = newFile.substring(0,newFile.length()-1);

            if (years<2011) {
                years = 2011;
            }

            String sqlCG = "";
            if (year_cs==null) {
                sqlCG = "BEGIN\n" +
                        "  MIGRATE_TABLE2('PCISV6_2."+table_new_one+"', '"+years+"','"+newFile+"','"+fileds+"','"+sql+"');\n" +
                        "END;";

            }
            else {
                sqlCG = "BEGIN\n" +
                        "  MIGRATE_TABLE_NOYEAR('PCISV6_2."+table_new_one+"','"+newFile+"','"+fileds+"','"+sql+"');\n" +
                        "END;";
            }
            System.out.println(sqlCG);
            try {
                String creatOracle = masterOracleMapper.creatOracle(sqlCG);
            }catch (Exception e){
                e.printStackTrace();
                continue;
            }
        }
        System.out.println(sql+"结束");
        return true;
    }


    public boolean selectTableIsOK(){
        try {
            LocalDate today = LocalDate.now();
            LocalDate yesterday = today.minusDays(1);
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
            String yesterdayFormatted = yesterday.format(formatter);

            String sql = "SELECT COUNT(1) FROM MIGRATION_LOG_END WHERE PROCEDURE_NAME='备份-中转' AND MESSAGETIME='"+yesterdayFormatted+"' AND STATUSS='1'";
            List<Map<String, Object>> mapList = masterOracleMapper.creatOracleMap(sql);
            String value = String.valueOf(mapList.get(0).get("COUNT(1)"));

            if (value.equals("0")) {
                return false;
            }
            else {
                sql = "UPDATE MIGRATION_LOG_END SET STATUSS='2' WHERE PROCEDURE_NAME='备份-中转' AND MESSAGETIME='"+yesterdayFormatted+"' AND STATUSS='1'";
                masterOracleMapper.creatOracle(sql);
                return true;
            }

        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    public void tableTONewTableYearsCG2(List<Map<String,String>> OracleTableList){
        // 昨天日期
        LocalDate today = LocalDate.now();
        LocalDate yesterday = today.minusDays(1);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String yesterdayFormatted = yesterday.format(formatter);
        String todayFormatted = today.format(formatter);
        DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy");
        String years = today.format(formatter2);
        System.out.println("昨天日期：" + yesterdayFormatted);

        if (OracleTableList.size()>0) {
            List<OracleTable> extable = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;
            for (Map<String,String> tableOneMap : OracleTableList) {

                String table_load = tableOneMap.get("table_load");// 读取表
                String table_load_id = tableOneMap.get("table_load_id");
                String table_new = tableOneMap.get("table_new"); // 存储表
                String way = tableOneMap.get("way");
                String inc_field = tableOneMap.get("inc_field");
                String filed = tableOneMap.get("filed");
                String filed_n = tableOneMap.get("filed_n");
                String lowerCase = tableOneMap.get("lowerCase");
                String year_cs = tableOneMap.get("year_cs");
                String where_sql = tableOneMap.get("where_sql");


                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + table_load + " 开始");
                String masterTableName = MasterDatabaseName + "." + table_load;

                String sql = "";
                sql = sql + " "+inc_field+">=TO_DATE(''"+yesterdayFormatted+"'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''"+todayFormatted+"'', ''YYYY-MM-DD'')";

                String fileds = "";
                if (filed==null || filed.equals("null")) {
                    OracleTable oracleTableLOad = selectOracle(MasterDatabaseName, table_load);
                    if (oracleTableLOad.getFieldList().size()>0) {
                        for (OracleField oracleField : oracleTableLOad.getFieldList()) {
                            fileds = fileds + oracleField.getCOLUMN_NAME() + ",";
                        }
                        fileds=fileds.substring(0,fileds.length()-1);
                    }
                }
                else {
                    fileds = filed;
                }

                if (filed_n==null || filed_n.equals("null")) {
                    filed_n = fileds;
                    if (lowerCase==null) {
                        filed_n = filed_n.toLowerCase();
                    }
                }
                else {
                    if (lowerCase==null) {
                        filed_n = filed_n.toLowerCase();
                    }
                }

                // 根据表名增加特殊需where条件
                if (table_new.equals("WEB_CLM_RPT")
                        ||table_new.equals("WEB_CLM_ACCDNT")
                        ||table_new.equals("WEB_CLM_CASE_STATE")) {
                    sql = masterTableName + " WHERE" + sql + " AND C_CLM_NO IN (SELECT C_CLM_NO FROM WEB_CLM_MAIN_END)";
                }
                else if(where_sql!=null){
                    sql = where_sql.replace("${WHERE}",sql);
                }
                else {
                    sql = masterTableName + " WHERE" + sql;
                }


                for (String table_new_one : table_new.split(",")) {
                    System.out.println("执行存过开始");
                    String newFile = "";
                    for (String string : filed_n.split(",")) {
                        newFile = newFile + "\""+string+"\",";
                    }
                    newFile = newFile.substring(0,newFile.length()-1);
                    String ids = tableOneMap.get(table_new_one+"_id");

                    String sqlCG = "";
                    if (year_cs==null) {
                        for (int i = 2011; i <= Long.parseLong(years); i++) {
                            sqlCG = "BEGIN\n" +
                                    "  MIGRATE_TABLE_YEAR_DELETE('PCISV6_2."+table_new_one+"', '"+i+"','\""+ids+"\"','"+table_load_id+"','"+sql+"');\n" +
                                    "END;";
                            System.out.println(sqlCG);
                            masterOracleMapper.creatOracle(sqlCG);
                        }
                    }
                    else {
                        sqlCG = "BEGIN\n" +
                                "  MIGRATE_TABLE_NOYEAR_DELETE('PCISV6_2."+table_new_one+"','\""+ids+"\"','"+table_load_id+"','"+sql+"');\n" +
                                "END;";
                        System.out.println(sqlCG);
                        masterOracleMapper.creatOracle(sqlCG);
                    }
                    System.out.println("删除完成");


                    sqlCG = "";
                    if (year_cs==null) {
                        sqlCG = "BEGIN\n" +
                                "  MIGRATE_TABLE2('PCISV6_2."+table_new_one+"', '"+years+"','"+newFile+"','"+fileds+"','"+sql+"');\n" +
                                "END;";

                    }
                    else {
                        sqlCG = "BEGIN\n" +
                                "  MIGRATE_TABLE_NOYEAR('PCISV6_2."+table_new_one+"','"+newFile+"','"+fileds+"','"+sql+"');\n" +
                                "END;";
                    }
                    System.out.println(sqlCG);
                    masterOracleMapper.creatOracle(sqlCG);
                    System.out.println("执行存过结束");
                }

                System.out.println("数据表名：" + table_load + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());

            if (extable.size()>0) {
                System.out.println("以下失败表名");
                for (OracleTable s : extable) {
                    System.out.println(s.getTableName());
                }
            }

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }
    }

    public void tableTONewTableYearsCG3(List<Map<String,String>> OracleTableList){
        // 昨天日期
        LocalDate today = LocalDate.now();
        LocalDate yesterday = today.minusDays(1);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String yesterdayFormatted = yesterday.format(formatter);
        String todayFormatted = today.format(formatter);
        DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy");
        String years = today.format(formatter2);
        System.out.println("昨天日期：" + yesterdayFormatted);

        if (OracleTableList.size()>0) {
            List<OracleTable> extable = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;
            for (Map<String,String> tableOneMap : OracleTableList) {

                String table_load = tableOneMap.get("table_load");// 读取表
                String table_load_id = tableOneMap.get("table_load_id");
                String table_new = tableOneMap.get("table_new"); // 存储表
                String way = tableOneMap.get("way");
                String inc_field = tableOneMap.get("inc_field");
                String filed = tableOneMap.get("filed");
                String filed_n = tableOneMap.get("filed_n");
                String lowerCase = tableOneMap.get("lowerCase");
                String year_cs = tableOneMap.get("year_cs");


                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + table_load + " 开始");
                String masterTableName = MasterDatabaseName + "." + table_load;


                StringBuffer stringBufferEnd = new StringBuffer();
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-02'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-02'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-03'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-03'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-04'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-04'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-05'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-05'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-06'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-06'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-07'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-07'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-08'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-08'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-09'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-09'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-10'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-10'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-11'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-11'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-12'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-12'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-13'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-13'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-14'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-14'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-15'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-16'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-16'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-17'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-17'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-18'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-18'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-19'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-19'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-20'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-20'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-21'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-21'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-22'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-22'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-23'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-23'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-24'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-24'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-25'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-25'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-26'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-26'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-27'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-27'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-28'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-28'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-29'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-29'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-30'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-30'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2024-12-31'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2024-12-31'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-01'', ''YYYY-MM-DD'');");

                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-02'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-02'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-03'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-03'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-04'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-04'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-05'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-05'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-06'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-06'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-07'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-07'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-08'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-08'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-09'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-09'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-10'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-10'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-11'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-11'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-12'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-12'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-13'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-13'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-14'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-14'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-15'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-16'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-16'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-17'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-17'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-18'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-18'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-19'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-19'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-20'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-20'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-21'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-21'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-22'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-22'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-23'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-23'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-24'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-24'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-25'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-25'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-26'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-26'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-27'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-27'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-28'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-28'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-29'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-29'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-30'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-30'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-01-31'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-01-31'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-01'', ''YYYY-MM-DD'');");

                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-02'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-02'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-03'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-03'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-04'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-04'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-05'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-05'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-06'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-06'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-07'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-07'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-08'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-08'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-09'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-09'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-10'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-10'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-11'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-11'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-12'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-12'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-13'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-13'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-14'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-14'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-15'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-16'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-16'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-17'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-17'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-18'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-18'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-19'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-19'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-20'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-20'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-21'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-21'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-22'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-22'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-23'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-23'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-24'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-24'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-25'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-25'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-26'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-26'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-27'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-27'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-02-28'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-02-28'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-01'', ''YYYY-MM-DD'');");

                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-02'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-02'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-03'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-03'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-04'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-04'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-05'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-05'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-06'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-06'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-07'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-07'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-08'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-08'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-09'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-09'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-10'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-10'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-11'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-11'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-12'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-12'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-13'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-13'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-14'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-14'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-15'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-16'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-16'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-17'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-17'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-18'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-18'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-19'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-19'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-20'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-20'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-21'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-21'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-22'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-22'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-23'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-23'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-24'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-24'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-25'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-25'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-26'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-26'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-27'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-27'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-28'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-28'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-29'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-29'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-30'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-30'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-03-31'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-03-31'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-01'', ''YYYY-MM-DD'');");

                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-02'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-02'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-03'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-03'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-04'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-04'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-05'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-05'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-06'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-06'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-07'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-07'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-08'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-08'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-09'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-09'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-10'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-10'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-11'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-11'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-12'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-12'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-13'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-13'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-14'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-14'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-15'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-16'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-16'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-17'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-17'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-18'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-18'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-19'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-19'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-20'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-20'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-21'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-21'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-22'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-22'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-23'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-23'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-24'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-24'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-25'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-25'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-26'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-26'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-27'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-27'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-28'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-28'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-29'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-29'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-04-30'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-04-30'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-01'', ''YYYY-MM-DD'');");

                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-01'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-02'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-02'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-03'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-03'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-04'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-04'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-05'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-05'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-06'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-06'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-07'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-07'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-08'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-08'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-09'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-09'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-10'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-10'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-11'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-11'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-12'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-12'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-13'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-13'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-14'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-14'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-15'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-15'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-16'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-16'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-17'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-17'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-18'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-18'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-19'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-19'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-20'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-20'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-21'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-21'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-22'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-22'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-23'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-23'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-24'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-24'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-25'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-25'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-26'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-26'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-27'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-27'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-28'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-29'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-30'', ''YYYY-MM-DD'');");
                stringBufferEnd.append(masterTableName + " WHERE "+inc_field+">=TO_DATE(''2025-05-30'', ''YYYY-MM-DD'') AND "+inc_field+"<TO_DATE(''2025-05-31'', ''YYYY-MM-DD'');");

                String fileds = "";
                if (filed==null || filed.equals("null")) {
                    OracleTable oracleTableLOad = selectOracle(MasterDatabaseName, table_load);
                    if (oracleTableLOad.getFieldList().size()>0) {
                        for (OracleField oracleField : oracleTableLOad.getFieldList()) {
                            fileds = fileds + oracleField.getCOLUMN_NAME() + ",";
                        }
                        fileds=fileds.substring(0,fileds.length()-1);
                    }
                }
                else {
                    fileds = filed;
                }

                if (filed_n==null || filed_n.equals("null")) {
                    filed_n = fileds;
                    if (lowerCase==null) {
                        filed_n = filed_n.toLowerCase();
                    }
                }
                else {
                    if (lowerCase==null) {
                        filed_n = filed_n.toLowerCase();
                    }
                }

                for (String sql : stringBufferEnd.toString().split(";")) {

                    // 根据表名增加特殊需where条件
                    if (table_new.equals("WEB_CLM_RPT")
                            ||table_new.equals("WEB_CLM_ACCDNT")) {
                        sql = sql + " AND C_CLM_NO IN (SELECT C_CLM_NO FROM WEB_CLM_MAIN_END)";
                    }

                    for (String table_new_one : table_new.split(",")) {
                        System.out.println("执行存过开始");
                        String newFile = "";
                        for (String string : filed_n.split(",")) {
                            newFile = newFile + "\""+string+"\",";
                        }
                        newFile = newFile.substring(0,newFile.length()-1);
                        String ids = tableOneMap.get(table_new_one+"_id");

                        String sqlCG = "";
                        if (year_cs==null) {
                            for (int i = 2011; i <= Long.parseLong(years); i++) {
                                sqlCG = "BEGIN\n" +
                                        "  MIGRATE_TABLE_YEAR_DELETE('PCISV6_2."+table_new_one+"', '"+i+"','\""+ids+"\"','"+table_load_id+"','"+sql+"');\n" +
                                        "END;";
                                System.out.println(sqlCG);
                                masterOracleMapper.creatOracle(sqlCG);
                            }
                        }
                        else {
                            sqlCG = "BEGIN\n" +
                                    "  MIGRATE_TABLE_NOYEAR_DELETE('PCISV6_2."+table_new_one+"','\""+ids+"\"','"+table_load_id+"','"+sql+"');\n" +
                                    "END;";
                            System.out.println(sqlCG);
                            masterOracleMapper.creatOracle(sqlCG);
                        }
                        System.out.println("删除完成");


                        sqlCG = "";
                        if (year_cs==null) {
                            int years_ZS = Integer.parseInt(years);
                            if (sql.contains("2024")) {
                                years_ZS=2024;
                            }
                            else if (sql.contains("2025")){
                                years_ZS=2025;
                            }

                            sqlCG = "BEGIN\n" +
                                    "  MIGRATE_TABLE2('PCISV6_2."+table_new_one+"', '"+years_ZS+"','"+newFile+"','"+fileds+"','"+sql+"');\n" +
                                    "END;";

                        }
                        else {
                            sqlCG = "BEGIN\n" +
                                    "  MIGRATE_TABLE_NOYEAR('PCISV6_2."+table_new_one+"','"+newFile+"','"+fileds+"','"+sql+"');\n" +
                                    "END;";
                        }
                        System.out.println(sqlCG);
                        masterOracleMapper.creatOracle(sqlCG);
                        System.out.println("执行存过结束");
                    }

                }

                System.out.println("数据表名：" + table_load + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());

            if (extable.size()>0) {
                System.out.println("以下失败表名");
                for (OracleTable s : extable) {
                    System.out.println(s.getTableName());
                }
            }

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }
    }

    public void tableTONewTableCG(List<Map<String,String>> OracleTableList){
        if (OracleTableList.size()>0) {
            List<OracleTable> extable = new ArrayList<>();
            int count = OracleTableList.size();
            int number = 1;
            for (Map<String,String> tableOneMap : OracleTableList) {

                String table_load = tableOneMap.get("table_load");// 读取表
                String table_new = tableOneMap.get("table_new"); // 存储表
                String way = tableOneMap.get("way");
                String inc_field = tableOneMap.get("inc_field");
                String filed = tableOneMap.get("filed");
                String filed_n = tableOneMap.get("filed_n");
                String BTS = tableOneMap.get("BTS");

                System.out.println("=============================");
                System.out.println(number++ + "/" + count + " 数据表名：" + table_load + " 开始");
                String masterTableName = MasterDatabaseName + "." + table_load;

                for (int years = 2025; years <2026 ; years++) {
                    StringBuffer stringBufferEnd = new StringBuffer();

                    if (BTS.equals("B")) {
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-01-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-01-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-01-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-02-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-02-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-03-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-03-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-04-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-04-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-05-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-05-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-06-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-06-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-07-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-07-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-08-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-08-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-09-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-09-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-10-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-10-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-11-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-11-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-12-15'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-12-15'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+(years+1)+"-01-01'', ''YYYY-MM-DD'');");
                    }

                    else if (BTS.equals("S")) {
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-01-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-01-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-01-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-01-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-01-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-02-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-02-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-02-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-02-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-03-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-03-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-03-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-03-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-04-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-04-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-04-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-04-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-05-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-05-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-05-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-05-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-06-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-06-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-06-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-06-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-07-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-07-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-07-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-07-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-08-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-08-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-08-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-08-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-09-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-09-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-09-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-09-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-10-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-10-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-10-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-10-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-11-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-11-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-11-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-11-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-12-11'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-12-11'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-12-21'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-12-21'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+(years+1)+"-01-01'', ''YYYY-MM-DD'');");
                    }

                    else if (BTS.equals("M")) {
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-01-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-02-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-03-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-04-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-05-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-06-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-07-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-08-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-09-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-10-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-11-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'');");
                        stringBufferEnd.append(masterTableName+" WHERE T_UPD_TM>=TO_DATE(''"+years+"-12-01'', ''YYYY-MM-DD'') AND T_UPD_TM<TO_DATE(''"+(years+1)+"-01-01'', ''YYYY-MM-DD'');");
                    }

                    String fileds = "";
                    if (filed==null || filed.equals("null")) {
                        OracleTable oracleTableLOad = selectOracle(MasterDatabaseName, table_load);
                        if (oracleTableLOad.getFieldList().size()>0) {
                            for (OracleField oracleField : oracleTableLOad.getFieldList()) {
                                fileds = fileds + oracleField.getCOLUMN_NAME() + ",";
                            }
                            fileds=fileds.substring(0,fileds.length()-1);
                            if (filed_n==null || filed_n.equals("null")) {
                                filed_n = fileds;
                            }
                        }
                    }
                    else {
                        fileds = filed;
                    }

                    for (String sql : stringBufferEnd.toString().split(";")) {

                        for (String table_new_one : table_new.split(",")) {
                            System.out.println("执行存过开始");
                            String newFile = fileds;
                            String sqlCG = "BEGIN\n" +
                                    "  MIGRATE_TABLE_TO_NTAB('PCISV6."+table_new_one+"','"+newFile+"','"+fileds+"','"+sql+"');\n" +
                                    "END;";
                            System.out.println(sqlCG);
                            String creatOracle = masterOracleMapper.creatOracle(sqlCG);
                            System.out.println("执行存过结束"+creatOracle);
                        }
                    }
                }

                System.out.println("数据表名：" + table_load + " 结束");
                System.out.println("=============================");

            }

            System.out.println("迁移完成，失败数为：" + extable.size());

            if (extable.size()>0) {
                System.out.println("以下失败表名");
                for (OracleTable s : extable) {
                    System.out.println(s.getTableName());
                }
            }

        }
        else {
            System.out.println("没有数据表！！！功能执行结束");
        }
    }

    public void tableYearCreat(Map<String,String> stringMap){
        String table = String.valueOf(stringMap.get("table"));
        for(int y=2012; y<=2025; y++) {
            String sql = String.valueOf(stringMap.get("sql"));
            sql = sql.replaceAll(table, table+y);
            for (String string : sql.split(";")) {
                System.out.println(string);
                slaveOracleMapper.creatOracle(string);
            }
        }
    }

    private int getMaxDayOfMonth(int year, int month) {
        if (month == 4 || month == 6 || month == 9 || month == 11) {
            return 30; // 4、6、9、11月30天
        } else if (month == 2) {
            // 处理闰年2月（闰年条件：能被4整除但不能被100整除，或能被400整除）
            boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
            return isLeapYear ? 29 : 28;
        } else {
            return 31; // 1、3、5、7、8、10、12月31天
        }
    }

    ///////////////////////////////////////////////////////////////////////////
    // todo Oracle 数据表对比
    // 用途：系统开发期间，多个环境，数据库有可能加字段了，但是你不知道具体加了什么，用这个脚本同步一下字段
    // 增加能够同步基础数据，但是只能说某一个表全量数据覆盖，不能单独加一条数据
    // todo dataBaseName 数据库名称
    // todo tableList 如果不是全部表对比，对比单独几个表，写这里，否则就是null
    // todo transferTable 需要覆盖基础数据的表
    ///////////////////////////////////////////////////////////////////////////
    @Override
    public void OracleToField(String dataBaseName, List<String> tableList, List<String> transferTable) throws IOException {
        SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        MasterUsername = MasterUsername.toUpperCase();

        List<String> list = new ArrayList<>();
        if (tableList!=null && tableList.size()>0) {
            list.addAll(tableList);
        }
        else if (StringUtils.isNotBlank(dataBaseName)) {
            list = masterOracleMapper.selectTableNameAllToDataBase(dataBaseName);
        }

        if (list.size()<1) {
            System.out.println("没有数据表！！！功能执行结束");
            return;
        }

        List<OracleTable> extable = new ArrayList<>();

        int count = list.size();
        int number = 1;

        for (String tableName : list) {

            System.out.println("=============================");
            System.out.println("开始时间：" + sdf.format(new Date()));
            System.out.println(number++ + "/" + count + " 数据表名：" + tableName + " 开始");
            OracleTable oracleTableOne = null;

            int selectTableNameOnDataBase = slaveOracleMapper.selectTableNameOnDataBase(dataBaseName, tableName);
            if (selectTableNameOnDataBase<1) {
                System.out.println("此数据表不存在，直接创建！！！");
                String selectTableCreatSql = masterOracleMapper.selectTableCreatSql(tableName);
                try {
                    String selectTableSplace = masterOracleMapper.selectTableSplace(dataBaseName, tableName);
                    selectTableSplace = "TABLESPACE \""+selectTableSplace+"\" ";
                    selectTableCreatSql = selectTableCreatSql.replaceAll(selectTableSplace,"");
                    System.out.println(selectTableCreatSql);
                    slaveOracleMapper.creatOracle(selectTableCreatSql);
                    System.out.println("创建表成功！！！");
                }catch (Exception e){
                    oracleTableOne.setTableName(tableName);
                    oracleTableOne.setExMessage("创建表失败 ：" + selectTableCreatSql);
                    extable.add(oracleTableOne);
                    continue;
                }
            }
            else {
                System.out.println("数据表存在，开始获取字段");

                oracleTableOne = selectOracle(dataBaseName, tableName);
                if (oracleTableOne.getFieldList().size() < 1) {
                    oracleTableOne.setExMessage("原始数据库或取字段失败，可能是因为没有表的原因或者其他！！！");
                    extable.add(oracleTableOne);
                    continue;
                }

                QueryWrapper<Object> queryWrapper = new QueryWrapper<>();
                queryWrapper
                        .eq("TABLE_NAME",oracleTableOne.getTableName()).eq("OWNER",dataBaseName).orderByAsc("COLUMN_ID");
                List<OracleField> oracleFields = slaveOracleMapper.selectTableNameOnCNAndTP(queryWrapper);
                List<OracleField> oracleFieldsEnd = new ArrayList<>();
                if (oracleFields.size()>0) {
                    for (OracleField oracleField : oracleFields) {
                        if (oracleField.getDATA_TYPE().equals("RAW")) {
                            System.out.println("发现奇异字段 "+oracleField.getCOLUMN_NAME()+" 将其过滤掉！!!");
                        }
                        else {
                            oracleFieldsEnd.add(oracleField);
                        }
                    }
                }
                System.out.println("目标表字段数量："+oracleFieldsEnd.size());

                // 对比注释
                List<OracleField> oracleFieldZS = masterOracleMapper.selectCommot(oracleTableOne.getTableName());
                if (oracleFieldZS!=null) {
                    if (oracleFieldZS.size()>0) {
                        for (OracleField oracleField : oracleTableOne.getFieldList()) {
                            for (OracleField field : oracleFieldZS) {
                                if (oracleField.getCOLUMN_NAME().equals(field.getCOLUMN_NAME())) {
                                    oracleField.setZHU_SHI(field.getZHU_SHI());
                                    break;
                                }
                            }
                        }
                    }
                }

                //判断主键
                List<String> zhujianlist = masterOracleMapper.selectTableId(oracleTableOne.getTableName());
                if (zhujianlist.size()>0) {
                    for (String s : zhujianlist) {
                        for (OracleField oracleField : oracleTableOne.getFieldList()) {
                            if (s.equals(oracleField.getCOLUMN_NAME())) {
                                oracleField.setZHU_JIAN(1);
                                break;
                            }
                        }
                    }
                }

                boolean exc = false;
                for (OracleField fieldOne : oracleTableOne.getFieldList()) {
                    boolean OK = false;
                    for (OracleField fieldTwo : oracleFieldsEnd) {
                        if (fieldOne.getCOLUMN_NAME().equals(fieldTwo.getCOLUMN_NAME())) {
                            System.out.println("字段："+fieldOne.getCOLUMN_NAME()+"在目标表中，不需要处理！！！");
                            OK = true;
                            break;
                        }
                    }
                    if (!OK) {
                        System.out.println("字段："+fieldOne.getCOLUMN_NAME()+"不在目标表中，需要新增！！！");

                        String sql = "ALTER TABLE \""+dataBaseName+"\".\""+tableName+"\" ADD (";
                        if (fieldOne.getDATA_TYPE().equals("VARCHAR2") || fieldOne.getDATA_TYPE().equals("NVARCHAR2")) {
                            sql = sql + fieldOne.getCOLUMN_NAME() + " " + fieldOne.getDATA_TYPE() + "(" + fieldOne.getDATA_LENGTH() + ")";
                        }
                        else if (fieldOne.getDATA_TYPE().equals("NUMBER")) {
                            String lengths = "0";
                            if (StringUtils.isNotBlank(fieldOne.getDATA_SCALE()) && Long.parseLong(fieldOne.getDATA_SCALE()) > 0) {
                                if (StringUtils.isNotBlank(fieldOne.getDATA_PRECISION())) {
                                    lengths = fieldOne.getDATA_PRECISION() +","+ fieldOne.getDATA_SCALE();
                                }
                                else {
                                    lengths = fieldOne.getDATA_LENGTH() +","+ fieldOne.getDATA_SCALE();
                                }
                            }
                            else {
                                if (StringUtils.isNotBlank(fieldOne.getDATA_PRECISION())) {
                                    lengths = fieldOne.getDATA_PRECISION();
                                }
                                else {
                                    lengths = fieldOne.getDATA_LENGTH();
                                }
                            }
                            sql = sql + fieldOne.getCOLUMN_NAME() + " " + fieldOne.getDATA_TYPE() + "(" + lengths + ")";
                        }
                        else if (
                                fieldOne.getDATA_TYPE().equals("BLOB") ||
                                        fieldOne.getDATA_TYPE().equals("CLOB") ||
                                        fieldOne.getDATA_TYPE().equals("NCLOB") ||
                                        fieldOne.getDATA_TYPE().equals("DATE") ||
                                        fieldOne.getDATA_TYPE().equals("CHAR") ||
                                        fieldOne.getDATA_TYPE().equals("NCHAR") ||
                                        fieldOne.getDATA_TYPE().equals("TIMESTAMP(6)")
                        ) {
                            sql = sql + fieldOne.getCOLUMN_NAME() + " " + fieldOne.getDATA_TYPE();
                        }
                        sql = sql + ")";
                        System.out.println(sql);

                        try {
                            slaveOracleMapper.creatOracle(sql);
                            System.out.println("创建字段成功！！！");
                        }catch (Exception e){
                            oracleTableOne.setExMessage("创建字段失败 ：" + fieldOne.getCOLUMN_NAME());
                            extable.add(oracleTableOne);
                            exc = true;
                            break;
                        }

                        // 补充注释
                        if (StringUtils.isNotBlank(fieldOne.getZHU_SHI())) {
                            sql = "COMMENT ON COLUMN \""+dataBaseName+"\".\""+tableName+"\"."+fieldOne.getCOLUMN_NAME()+" IS '"+fieldOne.getZHU_SHI()+"'";
                            System.out.println(sql);
                            slaveOracleMapper.creatOracle(sql);
                            System.out.println("创建注释成功！！！");
                        }

                        // 如果是主键打上主键标记
                        if (fieldOne.getZHU_JIAN()==1) {
                            sql = "ALTER TABLE \""+dataBaseName+"\".\""+tableName+"\" ADD CONSTRAINT "+fieldOne.getCOLUMN_NAME()+" PRIMARY KEY ( "+fieldOne.getCOLUMN_NAME()+" )";
                            System.out.println(sql);
                            slaveOracleMapper.creatOracle(sql);
                            System.out.println("创建主键成功！！！");
                        }
                    }
                }
                if (exc) {
                    continue;
                }
            }

            // 迁移要覆盖的数据表
            if (transferTable!=null&&transferTable.size()>0) {
                System.out.println("迁移基础数据！！！");
                for (String transferTableName : transferTable) {
                    if (transferTableName.equals(tableName)) {
                        // 获取数据
                        tableName = dataBaseName+".\""+tableName+"\"";
                        List<Map<String, Object>> selectData = masterOracleMapper.selectData(tableName);
                        System.out.println("数据量为："+selectData.size());
                        if (selectData.size()<1) {
                            System.out.println("数据为空，跳过！！！");
                            continue;
                        }
                        // 清空目标数据表
                        String sql = "truncate table \""+tableName+"\"";
                        slaveOracleMapper.creatOracle(sql);
                        oracleTableOne.getDataList().addAll(selectData);
                        // 形成sql添加语句
                        String creatInsert = creatInsertOracle(oracleTableOne);
                        // 存储
                        try {
                            slaveOracleMapper.creatOracle(creatInsert);
                            System.out.println("完成存储！！");
                        }catch (Exception e){
                            System.out.println(creatInsert);
                            System.out.println("存储方法一失败！！！执行方法2号");
                            e.printStackTrace();
                            try {
                                ConnectionUtils connectionUtils = new ConnectionUtils();
                                connectionUtils.sqlConnection(creatInsert,SlaveUrl,SlaveUsername,SlavePassword);
                            }catch (Exception e2){
                                oracleTableOne.setExMessage("数据存储失败："+creatInsert);
                                System.out.println(oracleTableOne.getExMessage());
                                extable.add(oracleTableOne);
                                continue;
                            }
                        }
                    }
                }
            }

            System.out.println("数据表名：" + tableName + " 结束");
            System.out.println("结束时间："+ sdf.format(new Date()));
            System.out.println("=============================");

        }

        System.out.println("=============================");
        System.out.println("对比完成，失败数为：" + extable.size());

        if (extable.size()>0) {
            System.out.println("以下失败表名");
            StringBuffer stringBuffer = new StringBuffer();
            for (OracleTable s : extable) {
                System.out.println(s.getTableName() + "原因是：" + s.getExMessage());
                stringBuffer.append(s.getTableName() + "原因是：" + s.getExMessage());
            }
            TXTUtils.creatTxt("exception",stringBuffer.toString());
        }
    }

    @Override
    public void OracleToSqlToExcel(HttpServletResponse response){
        try {
            List<String> readFile = TXTUtils.readFile("oracle");
            List<Map<String,Object>> endList = new ArrayList<>();
            if (readFile.size()>0) {
                int u = 0;
                for (String sqlFile : readFile) {
                    Map<String,Object> map = new HashMap<>();
                    map.put("tableName",u+++"AB");
                    List<List<Object>> sheetDataList = new ArrayList<>();
                    String txtSQL = TXTUtils.getTxt(sqlFile);
                    String[] split = txtSQL.split(";");
                    List<Map<String, Object>> mapList = new ArrayList<>();
                    for (String string : split) {
                        List<Map<String, Object>> mapList1 = masterOracleMapper.creatOracleMap(string);
                        System.out.println(string);
                        System.out.println("结果为："+mapList1.get(0).get("COUNT(1)"));
                        Map<String, Object> put = new HashMap<>();
                        put.put(string,mapList1.get(0).get("COUNT(1)"));
                        mapList.add(put);
                    }
                    if (mapList.size()>0) {
                        // 表头数据
                        List<Object> head = new ArrayList<>();
                        for (Map.Entry<String, Object> stringObjectEntry : mapList.get(0).entrySet()) {
                            head.add(stringObjectEntry.getKey());
                        }
                        if (head.size()==1) {
                            head.add("");
                        }

                        // 将数据汇总
                        sheetDataList.add(head);
                        for (Map<String, Object> stringObjectMap : mapList) {
                            List<Object> list = new ArrayList<>();
                            for (Object o : head) {
                                list.add(stringObjectMap.get(o.toString()));
                            }
                            if (list.size()==1) {
                                list.add("");
                            }
                            sheetDataList.add(list);
                        }

                        List<Object> list = new ArrayList<>();
                        StringBuffer stringBuffer = new StringBuffer();
                        for (int i = 0; i < head.size(); i++) {
                            if (i==0) {
                                list.add(txtSQL);
                            }
//                        stringBuffer.append(head.get(i)+"("+mapList.get(0).get(head.get(i))+"),");
                        }
                        list.add(stringBuffer.toString());
                        sheetDataList.add(list);


                        list = new ArrayList<>();
                        for (int i = 0; i < head.size(); i++) {
                            list.add("");
                        }
                        sheetDataList.add(list);
                    }
                    map.put("sheetDataList",sheetDataList);
                    endList.add(map);
                }

                // 导出数据
                ExcelUtil.exportAll(response,null,"dataBaseToolExcel", endList);
            }
        }catch (Exception e){
            e.printStackTrace();
        }

    }

    ///////////////////////////////////////////////////////////////////////////
    // oracle 链接两个Oracle数据库，执行相同的语句查看结果
    ///////////////////////////////////////////////////////////////////////////
    boolean OracleToOracleSqlToOne = false;
    boolean OracleToOracleSqlToTwo = false;
    public void OracleToOracleSql(){
        try {

            System.out.println("开始获取时间范围");
            List<String> selectDates = new ArrayList<>();
//            selectDates.add("2000-10-01");
//            selectDates.add("2001-01-01");
//            selectDates.add("2001-04-01");
//            selectDates.add("2001-07-01");
//            selectDates.add("2001-10-01");
//            selectDates.add("2002-01-01");
//            selectDates.add("2002-04-01");
//            selectDates.add("2002-07-01");
//            selectDates.add("2002-10-01");
//            selectDates.add("2003-01-01");
//            selectDates.add("2003-04-01");
//            selectDates.add("2003-07-01");
//            selectDates.add("2003-10-01");
//            selectDates.add("2004-01-01");
//            selectDates.add("2004-04-01");
//            selectDates.add("2004-07-01");
//            selectDates.add("2004-10-01");
//            selectDates.add("2005-01-01");
//            selectDates.add("2005-04-01");
//            selectDates.add("2005-07-01");
//            selectDates.add("2005-10-01");
//            selectDates.add("2006-01-01");
//            selectDates.add("2006-04-01");
//            selectDates.add("2006-07-01");
//            selectDates.add("2006-10-01");
//            selectDates.add("2007-01-01");
//            selectDates.add("2007-04-01");
//            selectDates.add("2007-07-01");
//            selectDates.add("2007-10-01");
//            selectDates.add("2008-01-01");
//            selectDates.add("2008-04-01");
//            selectDates.add("2008-07-01");
//            selectDates.add("2008-10-01");
//            selectDates.add("2009-01-01");
//            selectDates.add("2009-04-01");
//            selectDates.add("2009-07-01");
//            selectDates.add("2009-10-01");
//            selectDates.add("2010-01-01");
//            selectDates.add("2010-04-01");
//            selectDates.add("2010-07-01");
            selectDates.add("2010-10-01");
            selectDates.add("2011-01-01");
            selectDates.add("2011-04-01");
            selectDates.add("2011-07-01");
            selectDates.add("2011-10-01");
            selectDates.add("2012-01-01");
            selectDates.add("2012-04-01");
            selectDates.add("2012-07-01");
            selectDates.add("2012-10-01");
            selectDates.add("2013-01-01");
            selectDates.add("2013-04-01");
            selectDates.add("2013-07-01");
            selectDates.add("2013-10-01");
            selectDates.add("2014-01-01");
            selectDates.add("2014-04-01");
            selectDates.add("2014-07-01");
            selectDates.add("2014-10-01");
            selectDates.add("2015-01-01");
            selectDates.add("2015-04-01");
            selectDates.add("2015-07-01");
            selectDates.add("2015-10-01");
            selectDates.add("2016-01-01");
            selectDates.add("2016-04-01");
            selectDates.add("2016-07-01");
            selectDates.add("2016-10-01");
            selectDates.add("2017-01-01");
            selectDates.add("2017-04-01");
            selectDates.add("2017-07-01");
            selectDates.add("2017-10-01");
            selectDates.add("2018-01-01");
            selectDates.add("2018-04-01");
            selectDates.add("2018-07-01");
            selectDates.add("2018-10-01");
            selectDates.add("2019-01-01");
            selectDates.add("2019-04-01");
            selectDates.add("2019-07-01");
            selectDates.add("2019-10-01");
            selectDates.add("2020-01-01");
            selectDates.add("2020-04-01");
            selectDates.add("2020-07-01");
            selectDates.add("2020-10-01");
            selectDates.add("2021-01-01");
            selectDates.add("2021-04-01");
            selectDates.add("2021-07-01");
            selectDates.add("2021-10-01");
            selectDates.add("2022-01-01");
            selectDates.add("2022-04-01");
            selectDates.add("2022-07-01");
            selectDates.add("2022-10-01");
            selectDates.add("2023-01-01");
            selectDates.add("2023-04-01");
            selectDates.add("2023-07-01");
            selectDates.add("2023-10-01");
            selectDates.add("2024-01-01");
            selectDates.add("2024-04-01");
            selectDates.add("2024-07-01");
            selectDates.add("2024-10-01");
            selectDates.add("2025-01-01");

            if (selectDates.size()<1) {
                System.out.println("没有时间范围数据");
                return;
            }

            for (int i = 0; i < selectDates.size(); i++) {
                OracleToOracleSqlToOne = false;
                OracleToOracleSqlToTwo = false;
                // 开始时间 结束时间
                String startDate="";
                String endDate="";
                startDate= selectDates.get(i);
                try {
                    endDate= selectDates.get(i+1);
                }catch (Exception e) {
                    break;
                }
                System.out.println("=============================");
                System.out.println("提取"+startDate+"到"+endDate+"的数据开始");

//                String sql = "SELECT\n" +
//                        "    COUNT(1),\n" +
//                        "    SUM(N_RATE) AS sum_n_rate,\n" +
//                        "    SUM(N_AMT) AS sum_n_amt,\n" +
//                        "    SUM(N_CALC_PRM) AS sum_n_calc_prm,\n" +
//                        "    SUM(N_PRM) AS sum_n_prm,\n" +
//                        "    SUM(N_AMT_VAR) AS sum_n_amt_var,\n" +
//                        "    SUM(N_CALC_PRM_VAR) AS sum_n_calc_prm_var,\n" +
//                        "    SUM(N_PRM_VAR) AS sum_n_prm_var,\n" +
//                        "    SUM(N_NOTAX_PRM) AS sum_n_notax_prm,\n" +
//                        "    SUM(N_NET_PRM) AS sum_n_net_prm\n" +
//                        "FROM \n" +
//                        "    pcisv6.web_ply_base\n" +
//                        "WHERE T_APP_TM >= TO_DATE('"+startDate+"', 'YYYY-MM-DD')\n" +
//                        "  AND T_APP_TM < TO_DATE('"+endDate+"', 'YYYY-MM-DD')";

                String sql = "SELECT COUNT(1) FROM pcisv6.WEB_CLM_PLY_BASE " +
                        "WHERE T_CRT_TM >= TO_DATE('"+startDate+"', 'YYYY-MM-DD') " +
                        " AND T_CRT_TM < TO_DATE('"+endDate+"', 'YYYY-MM-DD')";

                OracleToOracleSql2(sql,startDate,endDate);

                System.out.println("提取"+startDate+"到"+endDate+"的数据结束");
                System.out.println("=============================");
            }

            System.out.println("跑批结束");

        }catch (Exception e){
            e.printStackTrace();
        }
    }

    //跑批逻辑独立出来 发现报错，重新出发的机制
    public void OracleToOracleSql2(String sql,String startDate,String endDate) throws Exception{
        int threadCount = 2;
        CountDownLatch latch = new CountDownLatch(threadCount);

        final String[] oneData = {""};
        final String[] twoData = {""};
        final List<Map<String, Object>>[] listOne = new List[]{new ArrayList<>()};
        final List<Map<String, Object>>[] listtwo = new List[]{new ArrayList<>()};

        Thread thread1 = new Thread(()->{
            try {
                System.out.println(sql);
                List<Map<String,Object>> list = masterOracleMapper.creatOracleMap(sql);
                listOne[0] = list;
                String jsonString = JSON.toJSONString(list);
                oneData[0] = jsonString;
                System.out.println("备份库："+jsonString);
            }catch (Exception e){
                System.out.println("备份库失败");
                OracleToOracleSqlToOne = true;
                e.printStackTrace();
            }
            latch.countDown();
        });
        thread1.start();

        Thread thread2 = new Thread(()->{
            try {
                System.out.println(sql);
                List<Map<String,Object>> list = slaveOracleMapper.creatOracleMap(sql);
                listtwo[0] = list;
                String jsonString = JSON.toJSONString(list);
                twoData[0] = jsonString;
                System.out.println("迁移库："+jsonString);
            }catch (Exception e){
                System.out.println("迁移库失败");
                OracleToOracleSqlToTwo = true;
                e.printStackTrace();
            }
            latch.countDown();
        });
        thread2.start();

        try {
            // 等待所有线程执行完毕
            latch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        if (OracleToOracleSqlToOne || OracleToOracleSqlToTwo) {
            OracleToOracleSqlToOne=false;
            OracleToOracleSqlToTwo=false;
            System.out.println("有异常，重新跑批");
            OracleToOracleSql2(sql,startDate,endDate);
            return;
        }

        if (oneData[0].equals(twoData[0])) {
            System.out.println("数据一致");
        }
        else {
            System.out.println("数据不一致,开始核对细节");

            System.out.println("识别方式一：迁移库数据量小于备份库，查看创建时间是否在新操作。属于是增量数据,不属于迁移数据丢失");
            Map<String, Object> mapOne = listOne[0].get(0);
            Map<String, Object> mapTwo = listtwo[0].get(0);
            long lOne = Long.parseLong(String.valueOf(mapOne.get("COUNT(1)")));
            long lTwo = Long.parseLong(String.valueOf(mapTwo.get("COUNT(1)")));
            System.out.println("备份库数量："+lOne);
            System.out.println("迁移库数量："+lTwo);
            long lcha = lOne - lTwo;
            if (lTwo<lOne) {
                final int[] oneNumX = {0,0};
                System.out.println("迁移库数量小于备份库数量，差异是："+lcha);

//                // 执行是否当前时间的sql
//                String sql2 = "SELECT tableA.c_app_no,tableA.t_upd_tm,tableA.t_crt_tm,tableA.* FROM pcisv6.web_ply_base tableA " +
//                        "WHERE T_APP_TM >= TO_DATE('"+startDate+"', 'YYYY-MM-DD') AND T_APP_TM < TO_DATE('"+endDate+"', 'YYYY-MM-DD')" +
//                        " AND TO_DATE('2025-01-01', 'YYYY-MM-DD')<=t_crt_tm AND t_crt_tm < TO_DATE('2025-06-01', 'YYYY-MM-DD')";
//
//                CountDownLatch latch2 = new CountDownLatch(threadCount);
//
//                thread1 = new Thread(()->{
//                    try {
//                        System.out.println(sql2);
//                        List<Map<String,Object>> list = masterOracleMapper.creatOracleMap(sql2);
//                        oneNumX[0]=list.size();
//                        String jsonString = JSON.toJSONString(list);
//                        System.out.println("备份库："+jsonString);
//                    }catch (Exception e){
//                        System.out.println("识别方式一备份库失败");
//                        e.printStackTrace();
//                    }
//                    latch2.countDown();
//                });
//                thread1.start();
//
//                thread2 = new Thread(()->{
//                    try {
//                        System.out.println(sql2);
//                        List<Map<String,Object>> list = slaveOracleMapper.creatOracleMap(sql2);
//                        oneNumX[1]=list.size();
//                        String jsonString = JSON.toJSONString(list);
//                        System.out.println("迁移库："+jsonString);
//                    }catch (Exception e){
//                        System.out.println("识别方式一迁移库失败");
//                        e.printStackTrace();
//                    }
//                    latch2.countDown();
//                });
//                thread2.start();
//
//                try {
//                    // 等待所有线程执行完毕
//                    latch2.await();
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }

//                System.out.println("备份库sql2数量："+oneNumX[0]);
//                System.out.println("迁移库sql2数量："+oneNumX[1]);

            }
        }
    }


    ///////////////////////////////////////////////////////////////////////////
    // oracle迁移oracle后增量数据处理
    ///////////////////////////////////////////////////////////////////////////
    public void  OracleToOracleIncrement(String dataBaseName,List<String> OracleTableList,Map<String,String> tableZH) {

        for (String tableName : OracleTableList) {
            System.out.println("===============================");

            String endTableName = dataBaseName+"."+tableName;
            Integer slaveCount = slaveOracleMapper.selectDataCount(endTableName);
            Integer masterCount = masterOracleMapper.selectDataCount(endTableName);
            if (!slaveCount.equals(masterCount)){
                System.out.println("原始Oracle："+endTableName+" 数据量："+masterCount);
                System.out.println("迁移后Oracle："+tableName+" 数据量："+slaveCount);
                System.out.println("表"+tableName+"数据量不一致，需要补充");

                /**
                 * DM_RES_CLM_OS 整个换，这个表只留最后一个月的  跟据DRAWMON字段
                 * DM_RES_CLM_NUM 数据量变少了，不是那中累加的表只能清了冲迁移，跟据结案月看也是5月的数据没了
                 * DM_RES_CLM_PAID 数据量变少了，看结案月份只保留了4月和6月，5月都没了，还有空结案月不知道啥意思
                 * DM_RES_POLICY_EXPIRE_PREM 整个换，这个表只留最后一个月的  跟据STMON字段
                 * DM_RES_POLICY_PREMIUM 整体变化 这个表只留最后一个月的  跟据STMON字段
                 * DM_RES_POLICY_UNEXPIRE_PREM 整个换，这个表只留最后一个月的  跟据DRAWMON字段
                 *
                 * DM_RES_POLICY_REALPREMIUM 增量补充、缺少统计月度数据 跟据STMON字段
                 * LIST_CLM_SETTLED 已决清单增量数据拿过来，跟据 UNDERWRITEENDDATE 核赔时间 大于当前的逗得拿
                 * LIST_CLM_UNSETTLED 未决变化根据赔案号处理 需要做增加减少两个流程
                 * LIST_REINS_BILL_SLIP 查GENBILLNO账单号，排除法找到变化的数据
                 *
                 *
                 * DW_CLM_ADJUSTMENT_MAIN 跟据时间ETL_DATE 或者 INPUTDATE 获取增量的那一部分
                 * DW_CLM_CLAIM_MAIN 跟据时间ETL_DATE 或者 INPUTDATE 获取增量的那一部分
                 * DW_CLM_DIRECT_FEE_DETAIL  跟据时间ETL_DATE ，但是发现原始数据有少的，还有个主键DETAILNO
                 * DW_CLM_ENDCASE_TRACE 只保留最后一个月，整表更换
                 * DW_CLM_ESTIMATE_LOSS 这个表有新增时间的字段DATE_CREATED，但是有空的现象，空的数据无法判断哪些新增，只能把空的重新迁移
                 * DW_CLM_OS_DETAIL_KIND 跟据时间ETL_DATE ，但是发现原始数据还是有少的
                 * DW_CLM_PAID_DETAIL_KIND 跟据时间ETL_DATE ，但是发现原始数据还是有少的
                 * DW_REINS_CEDED_OS_CLAIM 跟据创建时间DATE_CREATED
                 * DW_REINS_OS_RECLAIM_SHARE_HIS 跟据时间字段DATE_CREATED查看增量
                 * DW_REINS_RECLAIM 跟据时间字段DATE_CREATED查看增量
                 * DW_REINS_RECLAIM_SHARE 跟据时间字段DATE_CREATED查看增量
                 *
                 * */

//                if (tableName.equals("DM_RES_CLM_OS")
//                        ||tableName.equals("DM_RES_CLM_NUM")
//                        ||tableName.equals("DM_RES_CLM_PAID")
//                        ||tableName.equals("DM_RES_POLICY_EXPIRE_PREM")
//                        ||tableName.equals("DM_RES_POLICY_PREMIUM")
//                        ||tableName.equals("DM_RES_POLICY_UNEXPIRE_PREM")
//                ) {
//                    List<String> strings = new ArrayList<>();
//                    strings.add(tableName);
//                    OracleToOracleTableList(dataBaseName,strings,true);
//                    System.out.println("二次核对");
//                    slaveCount = slaveOracleMapper.selectDataCount(endTableName);
//                    masterCount = masterOracleMapper.selectDataCount(endTableName);
//                    if (!slaveCount.equals(masterCount)){
//                        System.out.println("表"+tableName+"补充一次还是不对，请手动查看原因");
//                    }
//                    else {
//                        System.out.println("表"+tableName+"数据量同步成功");
//                    }
//                }
//                else if(tableName.equals("DM_RES_POLICY_REALPREMIUM")){
//
//                    String sql = "select MAX(STMON) AS STMON from "+dataBaseName+"."+tableName;
//                    String loadSTMON = null;
//                    sql = "select * from "+dataBaseName+"."+tableName+" where STMON > '"+loadSTMON+"'";
//
//                }
//                else {
//                    System.out.println("没有相应的处理方式");
//                }

            }
            else {
                System.out.println("表"+tableName+"数据量一致，无需补充");
            }
            System.out.println("===============================");
        }

    }

    ///////////////////////////////////////////////////////////////////////////
    // todo 辅助功能
    ///////////////////////////////////////////////////////////////////////////

    //1.获取所有的表
    public List<String> selectAllTableName(){
        return masterOracleMapper.selectTableNameAll();
    }

    //2.根据表名获取表结构
    public OracleTable selectOracle(String dataBaseName,String tableName){
        OracleTable oracleTable = new OracleTable();
        oracleTable.setTableName(tableName);
        oracleTable.setDataBaseName(dataBaseName);
        if (tableName.indexOf(".")!=-1) {
            tableName = tableName.substring(tableName.indexOf(".")+1, tableName.length());
        }
        oracleTable.setTableNameSlave(tableName);

        QueryWrapper<Object> queryWrapper = new QueryWrapper<>();
        queryWrapper
                .eq("atc.TABLE_NAME",tableName).eq("atc.OWNER",dataBaseName).orderByAsc("COLUMN_ID");
        List<OracleField> oracleFields = masterOracleMapper.selectTableNameOnCNAndTP(queryWrapper);

        List<OracleField> oracleFieldsEnd = new ArrayList<>();
        if (oracleFields.size()>0) {
            for (OracleField oracleField : oracleFields) {
                if (oracleField.getDATA_TYPE().equals("RAW")) {
                    System.out.println("发现奇异字段 "+oracleField.getCOLUMN_NAME()+" 将其过滤掉！!!");
                }
                else {
                    oracleFieldsEnd.add(oracleField);
                }
            }
        }

        oracleTable.getFieldList().addAll(oracleFieldsEnd);
        System.out.println("字段数量："+oracleFieldsEnd.size());

        return oracleTable;
    }
    public OracleTable selectOracleSlave(String dataBaseName,String tableName){
        OracleTable oracleTable = new OracleTable();
        oracleTable.setTableName(tableName);
        oracleTable.setDataBaseName(dataBaseName);
        if (tableName.indexOf(".")!=-1) {
            tableName = tableName.substring(tableName.indexOf(".")+1, tableName.length());
        }
        oracleTable.setTableNameSlave(tableName);

        QueryWrapper<Object> queryWrapper = new QueryWrapper<>();
        queryWrapper
                .eq("TABLE_NAME",tableName).eq("OWNER",dataBaseName).orderByAsc("COLUMN_ID");
        List<OracleField> oracleFields = slaveOracleMapper.selectTableNameOnCNAndTP(queryWrapper);

        List<OracleField> oracleFieldsEnd = new ArrayList<>();
        if (oracleFields.size()>0) {
            for (OracleField oracleField : oracleFields) {
                if (oracleField.getDATA_TYPE().equals("RAW")) {
                    System.out.println("发现奇异字段 "+oracleField.getCOLUMN_NAME()+" 将其过滤掉！!!");
                }
                else {
                    oracleFieldsEnd.add(oracleField);
                }
            }
        }

        oracleTable.getFieldList().addAll(oracleFieldsEnd);
        System.out.println("字段数量："+oracleFieldsEnd.size());

        return oracleTable;
    }

    //3.拼接目标数据库创建表语法
    public void creatTableSqlMysql(OracleTable oracleTable){

        StringBuffer buffer = new StringBuffer();

        buffer.append("create table "+oracleTable.getTableNameSlave()+"(");

        int y = 0;

        for (OracleField oracleField : oracleTable.getFieldList()) {

            if(y!=0){
                buffer.append(",");
            }
            ++y;

            // 关键字问题
            int FieldTrue = FieldTrue(oracleField.getCOLUMN_NAME());

            if (FieldTrue<1) {
                oracleField.setCOLUMN_NAME("`"+oracleField.getCOLUMN_NAME() + "S` ");
            }

            buffer.append("`"+oracleField.getCOLUMN_NAME() + "` ");

            // 类型问题
            String FieldType = FieldType(oracleField);

            if (StringUtils.isBlank(FieldType)) {
                oracleTable.setExMessage(oracleField.getDATA_TYPE() + "没有对应的数据类型");
                break;
            }

            oracleField.setMYSQL_FIELD_TYPE(FieldType);

            buffer.append(FieldType + " ");

            if (oracleField.getZHU_JIAN()==1) {

                // 抽出主键
                oracleTable.getFieldKeyList().add(oracleField.getCOLUMN_NAME());

            }
            else {

                //非空问题
                String FieldNotBank = FieldNotBank(oracleField);

                buffer.append(FieldNotBank + " ");

            }


            if (StringUtils.isNotBlank(oracleField.getZHU_SHI())) {
                buffer.append("COMMENT '" + specialSymbol(oracleField.getZHU_SHI()) + "'");
            }

        }

        buffer.append(")ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin");

        oracleTable.setTableSql(buffer.toString());

    }

    //3-1.字段名称与关键字做匹配
    public int FieldTrue(String name){

        return 1;
    }

    //3-3.字段非空问题
    public String FieldNotBank(OracleField oracleField){

        if (oracleField.getNULLABLE().equals("N")) {
            return "not null";
        }

        return "";
    }

    //4.形成添加语句 （Mysql）
    public String creatInsertMysql(OracleTable oracleTable,List<Map<String, Object>> dataList){

        StringBuffer stringBuffer = new StringBuffer();

        stringBuffer
                .append("insert into " + oracleTable.getTableNameSlave() + "(");

        int y = 0;
        for (OracleField oracleField : oracleTable.getFieldList()) {
            if (y!=0) {
                stringBuffer.append(",");
            }
            ++y;
            stringBuffer.append(oracleField.getCOLUMN_NAME());
        }
        y = 0;

        stringBuffer.append(") values ");

        if (dataList!=null) {
            for (Map<String, Object> stringObjectMap : dataList) {

                if (y!=0) {
                    stringBuffer.append(",");
                }
                ++y;

                stringBuffer.append("(");

                int a = 0;
                for (OracleField oracleField : oracleTable.getFieldList()) {
                    if (a!=0) {
                        stringBuffer.append(",");
                    }
                    ++a;
                    String filedTo = filedToMysql(oracleField, String.valueOf(stringObjectMap.get(oracleField.getCOLUMN_NAME())));
                    if (StringUtils.isBlank(filedTo)) {
                        filedTo = "";
                    }
                    stringBuffer.append(filedTo);
                }

                stringBuffer.append(")");

            }
        }
        else {
            for (Map<String, Object> stringObjectMap : oracleTable.getDataList()) {

                if (y!=0) {
                    stringBuffer.append(",");
                }
                ++y;

                stringBuffer.append("(");

                int a = 0;
                for (OracleField oracleField : oracleTable.getFieldList()) {
                    if (a!=0) {
                        stringBuffer.append(",");
                    }
                    ++a;
                    String filedTo = filedToMysql(oracleField, String.valueOf(stringObjectMap.get(oracleField.getCOLUMN_NAME())));
                    if (StringUtils.isBlank(filedTo)) {
                        filedTo = "";
                    }
                    stringBuffer.append(filedTo);
                }

                stringBuffer.append(")");

            }
        }


        return stringBuffer.toString();

    }

    //5.形成触发器语句
    public String creatTrigger(Map<String, Object> mapsTrigger){

        String TRIGGER_NAME = (String) mapsTrigger.get("TRIGGER_NAME");
        String TRIGGER_TYPE = (String) mapsTrigger.get("TRIGGER_TYPE");
        TRIGGER_TYPE = TRIGGER_TYPE.substring(0,TRIGGER_TYPE.indexOf(" "));
        String TRIGGERING_EVENT  = (String) mapsTrigger.get("TRIGGERING_EVENT");
        String TABLE_NAME = (String) mapsTrigger.get("TABLE_NAME");
        String TRIGGER_BODY = (String) mapsTrigger.get("TRIGGER_BODY");


        String trigger = "CREATE TRIGGER " +
                TRIGGER_NAME +
                " " + TRIGGER_TYPE +
                " " + TRIGGERING_EVENT +
                " ON " +
                TABLE_NAME +
                " FOR EACH ROW " +
                TRIGGER_BODY;

        return trigger;
    }

    public String creatIdOracle(String dataBaseName,String tableName,List<String> oracleFieldKeyList,List<Map<String, Object>> dataList){
        StringBuffer stringBufferEnd = new StringBuffer();
        stringBufferEnd
                .append("DELETE FROM " + dataBaseName + ".\"" + tableName + "\" WHERE ");
        int b = 0;
        for (Map<String, Object> stringObjectMap : dataList) {
            if (b!=0) {
                stringBufferEnd.append(" OR ");
            }
            int a = 0;
            for (String fieldKey : oracleFieldKeyList) {
                if (a == 0) {
                    stringBufferEnd
                            .append(""+fieldKey+"='"+stringObjectMap.get(fieldKey)+"'");
                    a = 1;
                }
                else {
                    stringBufferEnd
                            .append(" AND "+fieldKey+"='"+stringObjectMap.get(fieldKey)+"'");
                }
            }
            b = 1;
        }
        return stringBufferEnd.toString();
    }

    public String creatIdOracle2(String dataBaseName,String tableName,List<String> oracleFieldKeyList,List<Map<String, Object>> dataList){
        StringBuffer stringBufferEnd = new StringBuffer();
        stringBufferEnd
                .append("DELETE FROM " + dataBaseName + ".\"" + tableName + "\" WHERE ");
        int b = 0;
        for (Map<String, Object> stringObjectMap : dataList) {
            if (b!=0) {
                stringBufferEnd.append(" OR ");
            }
            int a = 0;
            for (String fieldKey : oracleFieldKeyList) {
                if (a == 0) {
                    stringBufferEnd
                            .append("\""+fieldKey+"\"='"+stringObjectMap.get(fieldKey.toUpperCase())+"'");
                    a = 1;
                }
                else {
                    stringBufferEnd
                            .append(" AND \""+fieldKey+"\"='"+stringObjectMap.get(fieldKey.toUpperCase())+"'");
                }
            }
            b = 1;
        }
        return stringBufferEnd.toString();
    }


    public String creatIdMysql(String tableName,List<String> oracleFieldKeyList,List<Map<String, Object>> dataList){
        StringBuffer stringBufferEnd = new StringBuffer();
        stringBufferEnd
                .append("DELETE FROM " + tableName + " WHERE ");
        int b = 0;
        for (Map<String, Object> stringObjectMap : dataList) {
            if (b!=0) {
                stringBufferEnd.append(" OR ");
            }
            int a = 0;
            for (String fieldKey : oracleFieldKeyList) {
                if (a == 0) {
                    stringBufferEnd
                            .append(fieldKey+"='"+stringObjectMap.get(fieldKey)+"'");
                    a = 1;
                }
                else {
                    stringBufferEnd
                            .append(" AND "+fieldKey+"='"+stringObjectMap.get(fieldKey)+"'");
                }
            }
            b = 1;
        }
        return stringBufferEnd.toString();
    }

    //形成添加语句 （Oracle）
    public String creatInsertOracle(OracleTable oracleTable){
        StringBuffer stringBufferEnd = new StringBuffer();
        stringBufferEnd.append("BEGIN \n");

        StringBuffer stringBufferOne = new StringBuffer();
        stringBufferOne
                .append("insert into " + oracleTable.getDataBaseName() + ".\"" + oracleTable.getTableName() + "\" (");
        int y = 0;
        for (OracleField oracleField : oracleTable.getFieldList()) {
            if (y!=0) {
                stringBufferOne.append(",");
            }
            ++y;
            stringBufferOne.append("\""+oracleField.getCOLUMN_NAME()+"\"");
        }
        stringBufferOne.append(") values ");

        for (Map<String, Object> stringObjectMap : oracleTable.getDataList()) {
            StringBuffer stringBufferTwo = new StringBuffer();
            stringBufferTwo.append("(");
            int a = 0;
            for (OracleField oracleField : oracleTable.getFieldList()) {
                if (a!=0) {
                    stringBufferTwo.append(",");
                }
                ++a;
                String filedTo = filedToOracle(oracleField, String.valueOf(stringObjectMap.get(oracleField.getCOLUMN_NAME())));
                if (StringUtils.isBlank(filedTo)) {
                    filedTo = "";
                }
                stringBufferTwo.append(filedTo);
            }
            stringBufferTwo.append(")");
            stringBufferEnd.append(stringBufferOne.toString() + stringBufferTwo.toString()+";");
        }

        stringBufferEnd.append(" \nEND; ");
        return stringBufferEnd.toString();

    }

    // 变更传参方式
    public String creatInsertOracle2(String dataBaseName,String tableName,List<OracleField> oracleFieldList,List<Map<String, Object>> dataList){
        StringBuffer stringBufferEnd = new StringBuffer();
        stringBufferEnd.append("BEGIN \n");
        StringBuffer stringBufferOne = new StringBuffer();
        stringBufferOne
                .append("insert into " + dataBaseName + ".\"" + tableName + "\" (");
        int y = 0;
        for (OracleField oracleField : oracleFieldList) {
            if (y!=0) {
                stringBufferOne.append(",");
            }
            ++y;
            stringBufferOne.append("\""+oracleField.getCOLUMN_NAME()+"\"");
        }
        stringBufferOne.append(") values ");

        for (Map<String, Object> stringObjectMap : dataList) {
            StringBuffer stringBufferTwo = new StringBuffer();
            stringBufferTwo.append("(");
            int a = 0;
            for (OracleField oracleField : oracleFieldList) {
                if (a!=0) {
                    stringBufferTwo.append(",");
                }
                ++a;
                String filedTo = "";
                if (tableName.equals("WEB_EDR_CMP_ITEM")) {
                    filedTo = filedToOracle2(oracleField, String.valueOf(stringObjectMap.get(oracleField.getCOLUMN_NAME())));
                }
                else {
                    filedTo = filedToOracle(oracleField, String.valueOf(stringObjectMap.get(oracleField.getCOLUMN_NAME())));
                }
                if (StringUtils.isBlank(filedTo)) {
                    filedTo = "";
                }
                stringBufferTwo.append(filedTo);
            }
            stringBufferTwo.append(")");
            stringBufferEnd.append(stringBufferOne.toString() + stringBufferTwo.toString()+";");
        }

        stringBufferEnd.append(" \nEND; ");
        return stringBufferEnd.toString();
    }

    // 小写字段的问题
    public String creatInsertOracle3(String dataBaseName,String tableName,List<OracleField> oracleFieldList,List<Map<String, Object>> dataList){
        StringBuffer stringBufferEnd = new StringBuffer();
        stringBufferEnd.append("BEGIN \n");
        StringBuffer stringBufferOne = new StringBuffer();
        stringBufferOne
                .append("insert into " + dataBaseName + ".\"" + tableName + "\" (");
        int y = 0;
        for (OracleField oracleField : oracleFieldList) {
            if (y!=0) {
                stringBufferOne.append(",");
            }
            ++y;
            stringBufferOne.append("\""+oracleField.getCOLUMN_NAME()+"\"");
        }
        stringBufferOne.append(") values ");

        for (Map<String, Object> stringObjectMap : dataList) {
            StringBuffer stringBufferTwo = new StringBuffer();
            stringBufferTwo.append("(");
            int a = 0;
            for (OracleField oracleField : oracleFieldList) {
                if (a!=0) {
                    stringBufferTwo.append(",");
                }
                ++a;
                String filedTo = filedToOracle(oracleField, String.valueOf(stringObjectMap.get(oracleField.getCOLUMN_NAME().toUpperCase())));
                if (StringUtils.isBlank(filedTo)) {
                    filedTo = "";
                }
                stringBufferTwo.append(filedTo);
            }
            stringBufferTwo.append(")");
            stringBufferEnd.append(stringBufferOne.toString() + stringBufferTwo.toString()+";");
        }

        stringBufferEnd.append(" \nEND; ");
        return stringBufferEnd.toString();
    }

    // 对存储的数据加一层过滤,处理特殊符号
    public String specialSymbol(String name){

        if (name.contains("'")) {
            name = name.replaceAll("'","\"");
        }

        if (name.contains("\\")) {
            name = name.replaceAll("\\\\", "\\\\\\\\");
        }

        return name;
    }

    // 字段类型与mysql类型作比对
    public String FieldType(OracleField oracleField){
        String name = oracleField.getDATA_TYPE();

        if (name.equals("VARCHAR2") || name.equals("NVARCHAR2")) {

            if (Long.parseLong(oracleField.getDATA_LENGTH()) >= 4000) {
                return "text";
            }

            return "varchar(" + oracleField.getDATA_LENGTH() +")";
        }

        if (name.contains("TIMESTAMP(")) {
            return "timestamp(6)";
        }

        if (name.equals("NUMBER")) { //decimal(10, 0)

            if (StringUtils.isNotBlank(oracleField.getDATA_SCALE()) && Long.parseLong(oracleField.getDATA_SCALE()) > 0) {
                if (StringUtils.isNotBlank(oracleField.getDATA_PRECISION())) {
                    return "decimal("+ oracleField.getDATA_PRECISION() +","+ oracleField.getDATA_SCALE() +")";
                }
                else {
                    return "decimal("+ oracleField.getDATA_LENGTH() +","+ oracleField.getDATA_SCALE() +")";
                }
            }
            else {
                if (StringUtils.isNotBlank(oracleField.getDATA_PRECISION())) {
                    return "integer(" + oracleField.getDATA_PRECISION() +")";
                }
                else {
                    return "integer(" + oracleField.getDATA_LENGTH() +")";
                }
            }

        }

        if (name.equals("BLOB") || name.equals("CLOB") || name.equals("NCLOB")){
            return "longblob";
        }

        if (name.equals("DATE")) {
            return "datetime(6)";
        }

        if (name.equals("CHAR") || name.equals("NCHAR")) {
            return "char";
        }

        return null;
    }

    // Mysql字段类型对比
    public String filedToMysql(OracleField oracleField,String name){

        // 存储数据过滤
        name = specialSymbol(name);

        String data_type = oracleField.getMYSQL_FIELD_TYPE();

        if (data_type.equals("text") || data_type.contains("varchar(") ||
                data_type.equals("longblob")  || data_type.equals("char")
        ) {

            if (name.equals("null")) {
                return "''";
            }

            return "'" + name +"'";

        }


        if (data_type.equals("timestamp(6)")) {

            if (name.equals("null")) {
                return "null";
            }
            return "'" + name +"'";
        }


        if (data_type.equals("date") || data_type.equals("datetime(6)")) {
            if (name.equals("null")) {
                return "NULL";
            }
            return "'" + name + "'";
        }


        if (data_type.contains("integer(") || data_type.contains("decimal(")) {

            return name;

        }

        return null;
    }

    // Oracle字段类型对比
    public String filedToOracle(OracleField oracleField,String name){

        name = specialSymbol(name);

        String data_type = oracleField.getDATA_TYPE();

        if (data_type.equals("VARCHAR2")
                || data_type.contains("NVARCHAR2")
                || data_type.equals("BLOB")
                || data_type.equals("CLOB")
                || data_type.equals("CHAR")
                || data_type.equals("NCLOB")
                || data_type.equals("LONG")
                || data_type.equals("NCHAR")
        ) {
            if (name.equals("null")) {
                return "''";
            }
            return "'" + name +"'";
        }

        else if (data_type.equals("DATE")) {
            if (name.equals("null")) {
                return "null";
            }
            if (name.indexOf(".")!=-1) {
                name = name.substring(0,name.indexOf("."));
            }
            return "TO_DATE('"+name+"', 'YYYY-MM-DD HH24:MI:SS')";
        }

        else if (data_type.equals("TIMESTAMP(6)")) {
            if (name.equals("null")) {
                return "null";
            }
            return "TO_TIMESTAMP('"+name+"', 'SYYYY-MM-DD HH24:MI:SS:FF6')";
        }

        else if (data_type.contains("NUMBER")) {
            if (name.equals("null")) {
                return "null";
            }
            return name;
        }

        System.out.println("没有对应的字段类型");
        return null;
    }
    // Oracle字段类型对比[特殊情况]
    public String filedToOracle2(OracleField oracleField,String name){

        name = specialSymbol(name);

        String data_type = oracleField.getDATA_TYPE();

        if (data_type.equals("VARCHAR2")
                || data_type.contains("NVARCHAR2")
                || data_type.equals("BLOB")
                || data_type.equals("CLOB")
                || data_type.equals("CHAR")
                || data_type.equals("NCLOB")
                || data_type.equals("LONG")
                || data_type.equals("NCHAR")
        ) {
            if (name.equals("null")) {
                if (oracleField.getCOLUMN_NAME().equals("C_UPD_CDE")) {
                    return "'null'";
                }
                return "''";
            }
            return "'" + name +"'";
        }

        else if (data_type.equals("DATE")) {
            if (name.equals("null")) {
                return "null";
            }
            if (name.indexOf(".")!=-1) {
                name = name.substring(0,name.indexOf("."));
            }
            return "TO_DATE('"+name+"', 'YYYY-MM-DD HH24:MI:SS')";
        }

        else if (data_type.equals("TIMESTAMP(6)")) {
            if (name.equals("null")) {
                return "null";
            }
            return "TO_TIMESTAMP('"+name+"', 'SYYYY-MM-DD HH24:MI:SS:FF6')";
        }

        else if (data_type.contains("NUMBER")) {
            if (name.equals("null")) {
                return "null";
            }
            return name;
        }

        System.out.println("没有对应的字段类型");
        return null;
    }
















    // 表数据存储
    public boolean inseBigData(List<Map<String, Object>> dataList,OracleTable oracleTable,List<OracleTable> extable) {

        try{
            oracleTable.setDataList(dataList);
        }catch (Exception e){
            oracleTable.setExMessage("读取数据失败，此问题出现概率低，目前发现可能性有：1.数据获取代码存在问题。 2.当前表不属于当前用户下。");
            extable.add(oracleTable);
            return false;
        }

        System.out.println("数据存储量：" + dataList.size());
        if (dataList.size()>0) {

            System.out.println("开始存储");

            // 形成添加语句
            String creatInsert = creatInsertMysql(oracleTable,null);

            // 执行存储数据
            try {

                slaveMysqlMapper.creatMysql(creatInsert);
                System.out.println("存储完成1");

            }catch (Exception e){

                System.out.println("存储方法一失败！！！执行方法2号");
                e.printStackTrace();

                try {

                    ConnectionUtils connectionUtils = new ConnectionUtils();
                    connectionUtils.sqlConnection(creatInsert,SlaveUrl,SlaveUsername,SlavePassword);
                    System.out.println("存储完成2");

                }catch (Exception e2){

                    oracleTable.setExMessage("数据存储二失败："+e.getMessage()+",insert语句为："+creatInsert+",存储失败，猜测原因：1.语句存在问题。2.数据表并非本程序创建，跟原始表可能存在差异导致");
                    System.out.println(e.getMessage());
                    extable.add(oracleTable);
                    return false;
                }

            }

        }

        return true;

    }

    // 表数据存储[增量方式]
    public boolean inseBigDataInc(List<Map<String, Object>> dataList,OracleTable oracleTable,List<OracleTable> extable) {

        System.out.println("组合删除");
        String creatIdOracle = creatIdMysql(oracleTable.getTableNameSlave(), oracleTable.getFieldKeyList(), dataList);
        try {
            System.out.println("执行删除");
            slaveMysqlMapper.creatMysql(creatIdOracle);
        }catch (Exception e){
            System.out.println("删除失败！！！");
            return false;
        }

        System.out.println("存储组合");
        String creatInsert = creatInsertMysql(oracleTable, dataList);
        // 执行存储数据
        try {
            slaveMysqlMapper.creatMysql(creatInsert);
        }catch (Exception e){
            System.out.println("存储失败！！！");
            return false;
        }

        System.out.println("存储完成");
        return true;
    }





}
